相关疑难解决方法(0)

实体框架 - 重用复杂类型

我在Code First Entity框架中有一个实体,目前看起来像这样:

public class Entity
{
    // snip ...

    public string OriginalDepartment { get; set; }
    public string OriginalQueue { get; set; }

    public string CurrentDepartment { get; set; }
    public string CurrentQueue { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我想为这些类型创建复杂类型,如下所示:

public class Location
{
    public string Department { get; set; }
    public string Queue { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我想在Current和Original中使用相同的类型:

public Location Original { get; set; }
public Location Current { get; set; }
Run Code Online (Sandbox Code Playgroud)

这是可能的,或者我需要创建两个复杂类型CurrentLocationOriginalLocation

public …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework ef-code-first

6
推荐指数
1
解决办法
3242
查看次数

标签 统计

c# ×1

ef-code-first ×1

entity-framework ×1