Linq SELECT with ExecuteQuery
asp.net, c#, linq, sql
Solution
Result of this query is not `int[]` but one row with numbers.
not good solution: use for every number:
int userID = db.ExecuteQuery<int>("SELECT UserID FROM ArcadeGames WHERE ID = " + gamePlayRecordID).Single();
int ipID = db.ExecuteQuery<int>("SELECT IPID FROM ArcadeGames WHERE ID = " + gamePlayRecordID).Single();
int gameID db.ExecuteQuery<int>("SELECT GameID FROM ArcadeGames WHERE ID = " + gamePlayRecordID).Single();
or Create sql query
db.ExecuteQuery<int>(@"
SELECT UserID FROM ArcadeGames WHERE ID = {0}
UNION ALL
SELECT IPID FROM ArcadeGames WHERE ID = {0}
UNION ALL
SELECT GameID FROM ArcadeGames WHERE ID = {0}",
gamePlayRecordID).ToList();
or Create class ...
Problem
I get the error: The type 'System.Int32[]' must declare a default (parameterless) constructor in order to be constructed during mapping. With the code: ``` var gamePlayRecord = db.ExecuteQuery<int[]>("SELECT UserID, IPID, GameID FROM ArcadeGames WHERE ID = " + gamePlayRecordID).Single(); var userID = gamePlayRecord[0]; var ipID = gamePlayRecord[1]; var gameID = gamePlayRecord[2]; ``` I know this is wrong, but can someone show me how to do it correctly without needing to create a new object preferably?