I have a hard time telling what operations in linq cause a SQL command to be issued to the database.
I know calling ToList() or iterating w/ foreach will cause the query to run but do Select and GroupBy cause the code to execute on the database?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, they don’t, if they’re correctly called on the
IQueryablerather than theIEnumerable, 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
IEnumerablerather thanIQueryable, you’ll run into a database query.