Reputation: 55
How can I get the first record in a table independent of the rows primary key?
I'm using MVC 4, with EF Code First and a database context, or will I have to use LINQ for this?
I think I can use db.ToList()
to get the list and then loop through the specific elements, but wouldn't that "download" the whole table?
Cause if it does Isn't it bad practice and inefficient?
EDIT: Meant to say "first record", sorry for any confusion :)
Upvotes: 0
Views: 2555
Reputation: 7385
Have you tried:
db.List.First();
Upvotes: 2