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 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法