Case 1: CodeRule contains List<CodeRuleLine> CodeRuleLines attribute.
CodeRuleDto contains the List<CodeRuleLineDto>CodeRuleLines property.
When CodeRule=>CodeRuleDto, List<CodeRuleLine> cannot directly convert List<CodeRuleLineDto>, so when setting the mapping, it should be
CreateMap<CodeRule, CodeRuleDto>()
.ForMember(dest => dest.CodeRuleLines, opt => opt.MapFrom(src => src.CodeRuleLines));
At the same time, the constructor of CodeRule should be initialized with CodeRuleLines = new List<CodeRuleLine>();.
However, since CodeRuleLine itself has the attribute of CodeRule CodeRule, and CodeRuleLineDto also has the attribute of CodeRuleDto CodeRule, it will report an error of self-reference cycle.
At this time, the mapping in the AutoMapperProfile() method should be changed to CreateMap<CodeRuleLine, CodeRuleLineDto>().ForMember(dest => dest.CodeRule,opt=>opt.Ignore());
Similar Posts:
- Vue Error: Error in render: “TypeError: Cannot read properties of null (reading ‘xxx’)” found in
- Failed to decode downloaded font [How to Solve]
- Type error: ‘tuple’ object is not callable and one of the solutions
- mybatisThere is no getter for property named ‘***’ in ‘class ***’
- event.srcElement And event.target The difference between
- Error message of V-IF and V-for mutually exclusive codes in Vue project
- Error 404 when accessing pictures in the project directory
- PING[ARC2]: Heartbeat failed to connect to standby ‘gqtzdb_dg’. Error is 16047
- How to Solve Error: ‘_TestResult’ object has no attribute ‘outputBuffer’
- Python oserror: [errno 22] invalid argument: emergence and solution