yes6641990 2016-10-20 08:51 采纳率: 0%
浏览 3073

我在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条回答 默认 最新

  • devmiao 2016-10-20 09:41
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog