我需要什么样的关系

德州697

我坚持要弄清楚这一点。MVC 5,EntityFramework我的项目围绕着Job。每个作业都有多个ChangeOrder。我的设置很好。一份工作有一个客户。那也很好。我的问题是客户员工。Customer类与CustomerEmployee类具有一对多关系。每个客户员工都有一个基本属性以及一个Role属性。超级,PM,会计或管理员。好吧,当我创建工作时,我需要选择一个CustomerEmployee Admin / PM等。这是什么关系?多对多关系?在我看来,Job类需要具有一个CustomerEmployeeSuperId,CustomerEmployeePMId,CustomerEmployeeAdminId和CustomerEmployeeAccountantId。

因为现在它只有CustomerEmployeeId

我该怎么做呢?当前设置

 public class Job
{
    //job
    public int JobId { get; set; }
    public int? JobNumber { get; set; }
    public string JobName { get; set; }
    public string JobDescription { get; set; }


    public int? GeoAreaId { get; set; }
    public virtual JobMisc.GeoArea GeoArea { get; set; }

    public int? JobClassId { get; set; }
    public virtual JobMisc.JobClass JobClass { get; set; }

    public int? JobTypeId { get; set; }
    public virtual JobMisc.JobType JobType { get; set; }

    public Int64? CustomerId { get; set; }
    public virtual Customer Customer { get; set; }

    public virtual ICollection<ChangeOrder> ChangeOrders { get; set; }
    public virtual ICollection<PurchaseOrder> PurchaseOrders { get; set; }

    public int? CustomerEmployeeId { get; set; }
    public virtual ICollection<CustomerEmployee> CustomerEmployees { get; set; }
}

public class Customer
{
   [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
   public Int64 CustomerId { get; set; }
    public string CustomerName { get; set; }
    public Int64? CustomerPhoneNumber { get; set; }
    public Int64? CustomerFaxNumber { get; set; }
    public string CustomerAddress { get; set; }
    public string CustomerCity { get; set; }
    public string CustomerState { get; set; }
    public int? CustomerZipcode { get; set; }
    public string CustomerWebsite { get; set; }
    public string CustomerOtherShit { get; set; }
    public bool? CustomerIsHidden { get; set; }

    public virtual ICollection<CustomerEmployee> CustomerEmployees { get; set; }
    public List<Job> Jobs { get; set; }
}

 public class CustomerEmployee
 {
    [Key]
    public int CustomerEmployeeId { get; set; }
    public string CustomerEmployeeFirstName { get; set; }
    public string CustomerEmployeeLastName { get; set; }
    public string CustomerEmployeeEmail { get; set; }
    public Int64? CustomerEmployeePhoneNumber { get; set; }
    public Int64? CustomerEmployeeCellNumber { get; set; }
    public Int64? CustomerEmployeeFaxNumber { get; set; }
    public bool? CustomerEmployeeIsHidden { get; set; }
    public string CustomerEmployeeRole { get; set; }

    public Int64? CustomerId { get; set; }
    public virtual Customer Customer { get; set; }

    public int? JobId { get; set; }
    public virtual ICollection<Job> Jobs { get; set; }
 }
兰斯·伦纳德

好吧,对于个人工作,这将是一对多的关系。对于多个工作,可能是很多对很多。

管理员的员工是否也可能被迫担任某些工作的测试员?

我建议为JobRoles创建一个子表,该子表链接到JobID,CustomerEmployeeID和JobRoleID(假设JobRoles灵活)。

希望这可以帮助...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章