Does calling Select() or GroupBy() in Linq to entities trigger querying the database?

No, they don't, if they're correctly called on the IQueryable rather than the IEnumerable they are compiled as expressions and will later be translated to SQL You can use the intellisense tooltip to see which will be the currently called method. If the first parameter of the extension method is IEnumerable rather than IQueryable you'll run into a database query.

No, they don't, if they're correctly called on the IQueryable rather than the IEnumerable, they are compiled as expressions and will later be translated to SQL. You can use the intellisense tooltip to see which will be the currently called method. If the first parameter of the extension method is IEnumerable rather than IQueryable, you'll run into a database query.

I thought it was only when you begin enumerating that the query is sent. – Mark Byers Jun 22 '10 at 20:54.

Thanks for the tip, but I don't think I can see a running Log in Linq-to-entities... – user169867 Jun 22 '10 at 20:41 You could perhaps look at this question and its answers: stackoverflow. Com/questions/137712/sql-tracing-linq-to-entities – Mark Byers Jun 22 '10 at 20:55.

No, calling Select() and GroupBy() will not hit the database. Only when the actual result is required (when enumerating, using ToList(), ToArray(), Count() etc) will the query get executed against the database.

No, Select, GroupBy and most other methods will not cause a database request. A database request will typically only be made when you do something that requires the results to be known, such as calling Count or ToList as you mentioned. To help you see when database queries are made it might help to log them.

Then as you step through the code you can see when the query is sent.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions