Tech
LINQ GroupBy: The Operator Everyone Uses Wrong
LINQ GroupBy: The Operator Everyone Uses Wrong
GroupBy in LINQ looks like SQL GROUP BY . It isn't. At least, not in the way you'd expect.
When you grasp the difference, you stop fighting the operator and start wielding it.
The SQL Mental Model (That Misleads You)
In SQL, GROUP BY collapses rows into aggregates:
SELECT CategoryId , COUNT ( * ) as Count , AVG ( Price ) as AvgPrice
FROM Products
GROUP BY CategoryId
Result...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to