2 ms·
In my experience, the SQL that LINQ generates typically is good, but LINQ may run part of the query or, rarely, even all of it client-side. For example, if you
by Someone 10y ago
In my experience, the SQL that LINQ generates typically is good, but LINQ may run part of the query or, rarely, even all of it client-side.
For example, if you want the top N items ordered by f(x), and LINQ doesn't know how to map f(x) to a SQL Server built-in, it has to pull the entire set over the wire, and find the top N client-side. Obviously, if your table is huge, performance won't be good.
That can even affect more than performance. For example, SQL Server orders GUIDs differently than .NET, and SQL Server's decimal isn't quite a IEEE float (https://msdn.microsoft.com/en-us/library/bb738633(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/bb738633(v=vs.110)....)