Last post Mar 02, 2020 05:42 AM by jiadongm
Mar 01, 2020 12:51 PM|rajemessage|LINK
Mar 01, 2020 01:28 PM|mgebhard|LINK
as tolist() execute the linq query, how can i find that which method executes the query. so that i do not have to put tolist every time?
Enumerating (looping) the IQueryable<T> type executes Entity Framework queries. The fundamentals are covered in the official Querying Data documentation.
Mar 01, 2020 06:08 PM|DA924|LINK
The link should help you. It talks about ToList() and many others.
Mar 02, 2020 05:42 AM|jiadongm|LINK
Common query methods are as follows:
When you want to get an item by primary key. This will return null if it can't find an item. It will look in the context before going to the database.
When you expect one or more items to be returned by a query but you only want to access the first item in your code (ordering could be important in the query here). This will throw an exception if the query does not return at least one item.
When you expect exactly one item to be returned by a query. This will throw an exception if the query does not return exactly one item.
For more details about LINQ-to-Entities queries, you can refer to