请教个问题:
我在EF6中 使用AutoMapper 在遇到有导航属性的映射 就会陷入死循环,不知道为什么?您有遇到过这个情况吗?
public static class EntityHelper
{
public static TV ExeView<TS, TV>(this TS source)
{
var config = new MapperConfiguration(c =>
{
c.CreateMap<ActionInfo, ActionInfoView>();
c.CreateMap<RoleInfo, RoleInfoView>();
c.CreateMap<UserAction, UserActionView>();
c.CreateMap<UserInfo, UserInfoView>();
c.CreateMap<WorkflowInstance, WorkflowInstanceView>();
c.CreateMap<WorkFlowModel, WorkFlowModelView>();
c.CreateMap<WorkflowStep, WorkflowStepView>();
});
var marper = config.CreateMapper();
return marper.Map<TV>(source);
}
}
转换
var list = sysUserinfo.Query(c => true).FirstOrDefault()
.ExeView<WorkflowStep, WorkflowStepView>();
view 类
public partial class WorkflowStepView
{
public int StepId { get; set; }
public int InstanceId { get; set; }
public int NextId { get; set; }
public int SubBy { get; set; }
public System.DateTime SubTime { get; set; }
public string Remark { get; set; }
public bool IsOver { get; set; }
public virtual WorkflowInstanceView WorkflowInstance { get; set; }
}
EFMODEL
public partial class WorkflowStep
{
public int StepId { get; set; }
public int InstanceId { get; set; }
public int NextId { get; set; }
public int SubBy { get; set; }
public System.DateTime SubTime { get; set; }
public string Remark { get; set; }
public bool IsOver { get; set; }
public virtual WorkflowInstance WorkflowInstance { get; set; }
}