You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the following code, I was expecting to see a more concise SQL query that includes only the projected fields, but instead the SQL query includes all fields:
var customer = _customers
.AsNoTracking()
.Select(e => new { e.Id, e.Referral, e.State, e.HomeAddress.City })
.ToList();
info: Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilderFactory[1]
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "e"."Id", "e"."CreatedBy", "e"."CreatedOn", "e"."Referral", "e"."RowVersion", "e"."State", "e"."UpdatedBy", "e"."UpdatedOn", "e.HomeAddress"."Id", "e.HomeAddress"."BillingAddressCustomerId", "e.HomeAddress"."City", "e.HomeAddress"."Country", "e.HomeAddress"."FormattedAddress", "e.HomeAddress"."HomeAddressCustomerId", "e.HomeAddress"."PostalCode", "e.HomeAddress"."Province", "e.HomeAddress"."StreetLine1", "e.HomeAddress"."StreetLine2"
FROM "Application"."Customers" AS "e"
LEFT JOIN "Application"."CustomerAddresses" AS "e.HomeAddress" ON "e"."Id" = "e.HomeAddress"."HomeAddressCustomerId"
ORDER BY "e"."Id"
As you can guess, the Customer entity has a child HomeAddress entity navigation (one-to-one). If I omit the e.HomeAddress.City from the projection, the resulting SQL query is correct (as in, it only includes the Id, Referral and State fields in the SELECT statement).
Are my expectations incorrect?
Thanks
Further technical details
EF Core version: 1.1.2
Database Provider: NpgSql
Operating system: Windows 10
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered:
Hi,
Using the following code, I was expecting to see a more concise SQL query that includes only the projected fields, but instead the SQL query includes all fields:
As you can guess, the
Customer
entity has a childHomeAddress
entity navigation (one-to-one). If I omit thee.HomeAddress.City
from the projection, the resulting SQL query is correct (as in, it only includes theId
,Referral
andState
fields in the SELECT statement).Are my expectations incorrect?
Thanks
Further technical details
EF Core version: 1.1.2
Database Provider: NpgSql
Operating system: Windows 10
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: