[英]Automapper ignoring nested property
I am trying to ignore nested property inside InProductionRWDto class.我试图忽略InProductionRWDto class 中的嵌套属性。
public class InProductionRWDto
{
public int InProductionRWId { get; set; }
public int InProductionId { get; set; }
public InProductionDto InProduction { get; set; }
public WareDto Ware { get; set; }
public int? WareQuantity { get; set; }
public decimal? WareLength { get; set; }
public string WareUnit { get; set; }
public int ToIssue { get; set; } = 1;
public int ToIssuePerBook { get; set; } = 1;
public int ToIssuePerSubOrder { get; set; } = 1;
public int PlannedToCut { get; set; }
public int Issued { get; set; }
public int TotalToIssue { get; set; }
public decimal? QtyWhDiff { get; set; }
public sbyte ProductionStateCode { get; set; }
}
But when I do that:但是当我这样做时:
CreateMap<InProductionRW, InProductionRWDto>()
.ForPath(dest => dest.InProduction.ParentReservation, opt => opt.Ignore());
Automapper is ignoring entire InProduction property. Automapper 忽略整个InProduction属性。
UPDATE!更新!
Maps for InProduction class生产中class的地图
CreateMap<InProduction, InProductionDto>();
CreateMap<InProductionDto, InProduction>();
Could someone help me on this one?有人可以帮我解决这个问题吗?
.PropInfo.DeclaringType.Name.Equals(PropInfo.PropertyType.Name) .PropInfo.DeclaringType.Name.Equals(PropInfo.PropertyType.Name)
I have solved the problem by deleting navigation properties from all of the DTO's.我通过从所有 DTO 中删除导航属性解决了这个问题。 They were causing circular references which ultimately was leading to StackOverFlow exception.它们导致循环引用,最终导致 StackOverFlow 异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.