Ron*_*rby 1 .net entity-framework workflow-foundation entity-framework-4.1
我正在使用EF4.1 DbContext代码生成,它会创建像这样的POCO实体:
public partial class Employee
{
public Employee()
{
this.Roles = new HashSet<Role>();
}
public System.Guid EmployeeGUID { get; set; }
public string EmployeeID { get; set; }
public string PIN { get; set; }
public string FullName { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string JobTitle { get; set; }
public string DepartmentDescription { get; set; }
public Nullable<System.DateTime> LatestHireDate { get; set; }
public string CompanyEmailAddress { get; set; }
public Nullable<System.Guid> SupervisorGUID { get; set; }
public string SupervisorFullName { get; set; }
public string SupervisorCompanyEmailAddress { get; set; }
public string JobCode { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是如何完成的?
我将创建代表真正需要序列化的DTO(数据传输对象),而不是序列化您的DBContext实体.然后,我会使用类似AutoMapper的东西将您的DBContext实体映射到您的DTO.
更新:这有点过时,但作者解释了AutoMapper的一些重要用途.
| 归档时间: |
|
| 查看次数: |
3681 次 |
| 最近记录: |