将复合主键映射为单个值对象(就DDD而言)?

时间:2019-04-11 11:23:43

标签: entity-framework nhibernate entity-framework-core entity-framework-core-2.2

在Entity Framework Core中是否可以将复合主键映射为单个Value Object?然后:它在LINQ查询中正常工作吗?

我知道在EF Core 2.2之前,对VO的支持不是很好。

public class AssignmentIdentity
{
    // ...
    public EmployeeIdentity EmployeeId { get; protected set }
    public TaskIdentity TaskId { get; protected set; }
}

public class Assignment
{
    // ...
    public AssignmentIdentity Id { get; protected set }
}

public class EmployeeIdentity
{
    // ...
    public String Identifier { get; protected set }
}

public class Employee
{
    // ...
    public EmployeeIdentity Id { get; protected set }
}

public class TaskIdentity
{
    // ...
    public String Identifier { get; protected set }
}

public class Task
{
    // ...
    public TaskIdentity Id { get; protected set }
}

是否可以在EF中映射它?请注意,在(n)Hibernate中可以进行此类映射和LINQ查询。我希望EF Core也能实现同样的目标...

0 个答案:

没有答案