Как я могу предотвратить левое соединение для собственных свойств в ядре платформы лица 3.1? - PullRequest
1 голос
/ 03 февраля 2020
public class Employee
{
    public string FullName { get; set; }
    public string Code { get; set; }
    public string Gender { get; set; }
    public string MaritalStatus { get; set; }
    public DateTime DateOfBirth { get; set; }
    public string Status { get; set; }

    // # Address
    public Address Address { get; set; }
}

public class Address
{
    public string Address1 { get; set; }
    public string? Address2 { get; set; }
    public string City { get; set; }
    public string? Region { get; set; }
    public string PostCode { get; set; }
    public Country Country { get; set; }

    private Address() {}
}
EntityConfiguration
public class EmployeeConfiguration : IEntityTypeConfiguration<Employee>
{
    public void Configure(EntityTypeBuilder<Employee> builder)
    {
        builder.OwnsOne(e => e.Address);
    }
}
Создано SQL
SELECT t."Id", t."BsonId", t."Code", t."CompanyId", t."Created", t."DateOfBirth", t."FullName", t."Gender", t."LastModified", t."MaritalStatus", t."Status", t1."Id", t1."Address_Address1", t1."Address_Address2", t1."Address_City", t1."Address_PostCode", t1."Address_Region"
  FROM (
      SELECT e."Id", e."BsonId", e."Code", e."CompanyId", e."Created", e."DateOfBirth", e."FullName", e."Gender", e."LastModified", e."MaritalStatus", e."Status"
      FROM "I180814-04-edm"."Employees" AS e
      ORDER BY (SELECT 1)
      LIMIT @__p_1 OFFSET @__p_0
  ) AS t
  LEFT JOIN (
      SELECT e0."Id", e0."Address_Address1", e0."Address_Address2", e0."Address_City", e0."Address_PostCode", e0."Address_Region", e1."Id" AS "Id0"
      FROM "I180814-04-edm"."Employees" AS e0
      INNER JOIN "I180814-04-edm"."Employees" AS e1 ON e0."Id" = e1."Id"
      WHERE (e0."Address_Region" IS NOT NULL) OR ((e0."Address_PostCode" IS NOT NULL) OR ((e0."Address_City" IS NOT NULL) OR ((e0."Address_Address2" IS NOT NULL) OR (e0."Address_Address1" IS NOT NULL))))
  ) AS t0 ON t."Id" = t0."Id"
  LEFT JOIN (
      SELECT e2."Id", e2."Address_Address1", e2."Address_Address2", e2."Address_City", e2."Address_PostCode", e2."Address_Region", e3."Id" AS "Id0"
      FROM "I180814-04-edm"."Employees" AS e2
      INNER JOIN "I180814-04-edm"."Employees" AS e3 ON e2."Id" = e3."Id"
      WHERE (e2."Address_Region" IS NOT NULL) OR ((e2."Address_PostCode" IS NOT NULL) OR ((e2."Address_City" IS NOT NULL) OR ((e2."Address_Address2" IS NOT NULL) OR (e2."Address_Address1" IS NOT NULL))))
  ) AS t1 ON t."Id" = t1."Id"

Я что-то пропустил? Я искал по всему, но я не мог найти, чтобы изменить сгенерированный SQL для OwnedProperties в ядре Ef. Есть ли способ настроить отношения так, чтобы ядро ​​проектировало свойства так, как если бы это была единая модель, а не определяло ее как отношение и создавало левое соединение.

...