我正在使用带有代码优先方法的实体框架 6。我们使用一个商业的、现成的软件解决方案,我将其整合到我们自己的自定义应用程序中。除了Employee,Salary,JobDetail的基本表之外,这是可能的:
myEmployee.First " " + myEmployee.Last;
myEmployee.Salary.Where(x => x.SalaryEndDate == null).FirstOrDefault().Amount.ToString();
它在数据库中也有一个自定义字段配置,如下所示:
自定义字段表:
GrpID CstmFldID CstmFldGrp CstmFldName
1 1 Education University
1 2 Education Degree
1 3 Education Major
2 1 Logistics EmergencyEmail
2 2 Logistics EmergencyPhone
2 3 Logistics EmergencyContact
自定义字段数据表:
CstmFldGrpID CustomField1 CustomField2 CustomField3 EmployeeID
1 George Washington Bachelors Philosophy 6548
1 Harvard University Masters Business Mgt 4687
2 emerg@contact.com 555-2020 John Adams 6548
2 emerg@harvard.edu 555-0001 Paul Revere 4687
您将如何将这些自定义字段映射到域实体?例如,我希望能够编写:
myEmployee.Education.University.ToString();
myEmployee.Logistics.EmergencyPhone.ToString();