Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with Linq query
    primarykey
    data
    text
    <p>I'm writing a linq query and I've run into trouble with it so I was wondering if someone could help. Here is a bit of background:</p> <p>I didn't design the database so the structure cannot be changed. So I have the Main 'Game' table, which has a main product code, A foreign key in this table is GameDataID from the GameData table which contains information such as release dates, released by, etc. Then I have the GameFormat table, which contains the product codes for the game in each format, e.g. Mac, Windows, etc and again the GameDataID is a foreign key. See Below.</p> <pre><code>Game GameID PK MainGameProductCode MainGameTitle GameDataID FK GameData GameDataID PK GameReleaseDate GameReleasedBy GameFormat GameFormatID PK GameDataID FK GameFormatProductcode </code></pre> <p>So when sales reports are received back, some only contain 'GameFormatProductCode' as the product identifier. So from 'GameFormatProductCode' I need to retrieve the 'GameID' in the main Game table. </p> <p>So far I have written the linq query to retrieve the GameFormatProductcode from the GameFormat table, however I am unsure how to go about retrieving the GameID from the main Game table.</p> <pre><code>private Int64 GetGameID(string gameFormatProductCode) { ModelCtn ctn = new ModelCtn(); Game game = null; GameFormat gf = null; gf = (from t in ctn.GameFormat where t.GameFormatProductcode == gameFormatProductCode select t).FirstOrDefault(); // Need to find GameID from Game table and return it. return gf; } </code></pre> <p>Any linq experts out there care to point me in the right direction? Very new to Linq so be gentle :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload