我被困在这个问题上。 MVC 5,EntityFramework 我的项目围绕着一个工作。每项工作都有多个ChangeOrders。我的设置很好。一份工作有一个客户。这工作也很好。我的问题是与客户员工。 Customer类与CustomerEmployee类具有一对多的关系。每位客户员工都具有基本属性和角色属性。超级,下午,会计或管理员。那么当我创建一份工作时,我需要选择一个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; }
}
我不在电脑前。当我回到家时,我会发布我的代码。感谢您的回应。 – texas697 2014-10-19 02:50:20
查看最新文章 – texas697 2014-10-19 15:39:21
你让我朝着正确的方向前进。我用这个作为指导,感谢http://www.ojdevelops.com/2014/01/multiple-many-to-many-associations.html – texas697 2014-10-19 16:38:08