<div>hi,</div> <div> </div> <div> as tolist() execute the linq query, how can i find that which method executes the query.</div> <div>so that i do not have to put tolist every time?</div> <div> </div> <div>yours sincerley </div>
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.
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.
2. First()
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.
3.Single()
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
16 Points
172 Posts
like tolist() how many functions are there.
Mar 01, 2020 12:51 PM|rajemessage|LINK
All-Star
53041 Points
23611 Posts
Re: like tolist() how many functions are there.
Mar 01, 2020 01:28 PM|mgebhard|LINK
Enumerating (looping) the IQueryable<T> type executes Entity Framework queries. The fundamentals are covered in the official Querying Data documentation.
https://docs.microsoft.com/en-us/ef/core/
https://docs.microsoft.com/en-us/ef/core/querying/
Contributor
4933 Points
4205 Posts
Re: like tolist() how many functions are there.
Mar 01, 2020 06:08 PM|DA924|LINK
The link should help you. It talks about ToList() and many others.
https://www.codeproject.com/Articles/286255/Using-LINQ-Queries
Participant
1320 Points
491 Posts
Re: like tolist() how many functions are there.
Mar 02, 2020 05:42 AM|jiadongm|LINK
Hi rajemessage,
Common query methods are as follows:
1. Find()
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.
2. First()
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.
3.Single()
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
https://www.entityframeworktutorial.net/querying-entity-graph-in-entity-framework.aspx
Best Regards,
Jiadong Meng