I am trying to select a list of objects from the db with a direct SQL command. db
is my dbContext
List<long> ids = db.Database.SqlQuery<List<long>>(sqlCommand).ToList();
My query, when tested in SQL (not that visual studio knows this) returns a list of ids, which are of type long. I want to return this list. I use ToList()
to force execution (since it's deferred until enumerated). However, I get a compile error saying that I cannot implicitly convert a generic list to list of type long.
How do I specify to List<long>
? This might be a completely stupid question, but I thought it took something of T
and converted it to a list of T
, which should be List<long>
here.