Geeks With Blogs
Juans and Zeros April 2013 Entries
Why Entity Framework Profiler is showing SELECT TOP 2 Queries
I was running Entity Framework Profiler on one of my projects using EF5 and came across several queries that were using SELECT TOP (2) and was wondering why that was happening. There were two different reasons I came across. Reason 1: When using Linq SingleOrDefault it will check to see if 2 results are returned so an exception can be thrown. This is per MSDN Instead I switched over to using Linq FirstOrDefault which translates to a SELECT TOP ......

Posted On Thursday, April 18, 2013 4:39 PM

Copyright © Juan | Powered by: