Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Answers


In case of Immediate query execution query is executed immediately or when we declare it, no matter whether collection is changed after it or not.

In Detail:

LINQ queries that return a singleton value are executed immediately. Some examples of singleton queries are Average, Count, First, and Max. These execute immediately because the query must produce a sequence to calculate the singleton result. You can also force immediate execution.

FollowingLINQ operators and extension methods supports immediate execution

1. All
2. Any
3. Contains
4. Count
5. First
6. FirstOrDefault
7. Last
8. LastOrDefault
9. Max
10. Min
11. Single
12. SingleOrDefault
13. Sum
14. ToArray
15. ToDictionary
16. ToList

Example:

// here query is executed immediately

varSampleQuery= SampleDbContext.user.FirstOrDefault(U=>U.Lastname=="Kendre");

Immediate execution doesn't provide the facility of query re-usability reason it produces result when we declare query. 

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.