SubSonic 3 - Simple repository - One to many relations

拜拜、爱过 提交于 2019-12-06 15:56:35

Based on your comment and the updated question it looks like you want something like the following:

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; }
}

You'll actually need a many-to-many relationship which will join an Employee record to a Store Record, with a payload of Start and End Dates.

The Objects will look like this:

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; }
}

Did this freehand so there could be a couple errors.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!