Grouping with LINQ
Hello!
I was unpleasantly surprised when I tried to use GroupBy operator in my LINQ query.
In his pocket reference on LINQ Joe is describing the GroupBy operator for LINQ2SQL and tells that it's so fine and it steps away from traditional SQL giving a possibilty not to select the grouping fields. But he's keeping strangely quiet of the fact that it emits multiple SQL queries, which is the crucial fact! It happens even when I select only the grouping fields. I need it to emit just 1 query. How to do this?
I was unpleasantly surprised when I tried to use GroupBy operator in my LINQ query.
In his pocket reference on LINQ Joe is describing the GroupBy operator for LINQ2SQL and tells that it's so fine and it steps away from traditional SQL giving a possibilty not to select the grouping fields. But he's keeping strangely quiet of the fact that it emits multiple SQL queries, which is the crucial fact! It happens even when I select only the grouping fields. I need it to emit just 1 query. How to do this?
Comments
But tell me please another thing. You say that grouping on the client is more efficient. But isn't the DB engine optimized at maximum degree to perform all the operations in the most effecient way?