I am writing a linq request and I had problems with this, so I was wondering if anyone could help. Here is some background:
I did not design the database, so the structure cannot be changed. Thus, I have a table "Main game" in which there is a main product code. The foreign key in this table is the GameDataID from the GameData table, which contains information such as release dates, released, etc. Then I have a GameFormat table that contains the product codes for the game in each format, for example Mac, Windows, etc. Again, GameDataID is a foreign key. See below.
Game
GameID PK
MainGameProductCode
MainGameTitle
GameDataID FK
GameData
GameDataID PK
GameReleaseDate
GameReleasedBy
GameFormat
GameFormatID PK
GameDataID FK
GameFormatProductcode
, , "GameFormatProductCode" . "GameFormatProductCode" "GameID" .
linq GameFormatProduct GameFormat, , GameID .
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();
return gf;
}
linq ? Linq :)