我在EF6中 使用AutoMapper 在遇到有导航属性的映射 就会陷入死循环

请教个问题:
我在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; }
}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐