1

这是我第一次使用亚音速。

假设我有这些课程:

public class Store
{
    public int Id { get; set; }
    public String Name { get; set; }
}

public class Employee
{
    public int Id { get; set; }
    public String Name { get; set; }
}

员工与具有雇用日期的商店相关。这意味着在数据库中我将​​有一个带有 StoreId、EmployeeId、StartDate、EndDate 的中间表

更新

员工可以从 2009-01-01 到 2009-04-04 到 StoreA 工作,从 2009-04-05 到…每次员工更换他工作的商店时。在这个例子中,员工只有一个名字,但假设一个员工有 10 个财产(地址、年龄、性别......)

我怎么能做到这一点?

4

2 回答 2

1

根据您的评论和更新的问题,您似乎想要以下内容:

public class Store
{
    public int Id { get; set; }
    public String Name { get; set; }
}

public class StoreEmployee
{
    public int Id { get; set; }
    public Employee Employee { get; set; }
    public Store Store { get; set; }
    public DateTime HiredDate { get; set; }
}

public class Employee
{
    public int Id { get; set; }
    public String Name { get; set; }
}
于 2009-08-19T15:34:25.970 回答
0

您实际上需要一个多对多关系,它将员工记录连接到商店记录,有效负载为开始日期和结束日期。

对象将如下所示:

public class Store
{
    public int Id { get; set; }
    public String Name { get; set; }
}

public class Employee
{
    public int Id { get; set; }
    public String Name { get; set; }
    public IList<EmploymentTerm> EmploymentTerms { get; set; }
}

public class EmploymentTerm
{
    public int Id { get; set; }
    public Store Store { get; set; }
    public Employee Employee { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
}

这是徒手做的,所以可能会有几个错误。

于 2009-11-08T01:21:30.640 回答