I have a linq query that retrieves rows from a view based on id column (where id = @id)
This request takes 4 seconds. I used SQL Server Profiler to verify the query that linq is executing, and if I copy this query directly to the management studio and execute, the query takes only 56 ms.
This exponential increase in time is consistent across all LINQ queries with the views in my application. What could be the reason for this extended runtime in my (WPF) application when the same requests are executed <100 ms?
== EDIT ==
I was able to further highlight, comments show the duration of the profiler;
context.SkuView.Where(p => p.TermId == 35 && !p.IsDeleted).ToList(); context.SkuView.Where(p => p.TermId == 35).ToList();
If I embed (sql rendered) linq queries directly in ssms, I get;
SELECT * FROM SkuView WHERE TermId == 35 AND IsDeleted = 0 SELECT * FROM SkuView WHERE TermId == 35
So the problem is reading count through linq when using! p.IsDeleted ...
source share