I am using .NET 4 and Entity Framework to create a simple query. Here's the C # code:
return Context.Files.Where(f => f.FileHash != 40) .OrderByDescending(f => f.Created) .Take(5);
When I trace the request with ObjectQuery.ToTraceString(), I find the following subquery:
ObjectQuery.ToTraceString()
SELECT TOP (5) [Project1].[ID] AS [ID], -- <snip> lots of columns [Project1].[FileHash] AS [FileHash] FROM ( SELECT [Extent1].[ID] AS [ID], -- <snip> lots of columns [Extent1].[FileHash] AS [FileHash] FROM [dbo].[Files] AS [Extent1] WHERE (LEN([Extent1].[FileHash])) <> 40 ) AS [Project1] ORDER BY [Project1].[Created] DESC
FileHash is defined as NVARCHAR (255) .
This seems strange to me because I donβt see the need for a subquery. Why does EF do this for me, and is there something I can do to not accept what I assume is a performance hit from such a request?
, , . , , EF "" , . , , EF . , , .
, EF , , , LINQ SQL-. , , , , , , . , , "" , , SQL Server.
Source: https://habr.com/ru/post/1759431/More articles:Where can I get a sample application for pcclinic for Spring 3.0? - javaHow to avoid adding jsession id in url? - javaJquery click event not working on div loaded with ajax - jqueryInternationalizing Django with i18n: choosing a language in a template using jQuery - jqueryInstalling multiple packages from one source - javaHow can I limit the number of words displayed in a Ruby string? - ruby ββ| fooobar.comWhat do I need to use Markdown in Java Webapp? - javaWordpress - Contact Form 7 Do Not Send To A Specific Address - EmailHibernate annotation issue with JodaTime - javaIs there any way to debug using the visual studio command line? - c ++All Articles