question

AsjadButt-2119 avatar image
0 Votes"
AsjadButt-2119 asked ZhiLv-MSFT commented

Help me put with this mapping profile

So there is this add class method and is giving a maping type error i amunable to understand why
[HttpPost]
public async Task<IActionResult> AddClass(StudyClassDto studyClassDto)
{
var studyclass = mapper.Map<StudyClass>(studyClassDto);
uow.StudyClassRepository.AddStudyClass(studyclass);
await uow.SaveAsync();
return Ok();
}
and the mapping type

             CreateMap<StudyClassDto, StudyClass>()
                 .ForMember(dest => dest.AppUserId, opt => opt.MapFrom(src => src.TeacherId));

i just need the id here


dotnet-aspnet-core-webapidotnet-aspnet-mvcdotnet-aspnet-core-security
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So there is this add class method and is giving a mapping type error i am unable to understand why

What is the error?

Can you explain the design approach where TeacherId is an alias for AppUserId? Seems like a very confusing design bug.

Can you also explain the troubleshooting steps performed? Does TeacherId have a value? If so, what is the value? Does the value exist in the Identity User table?

0 Votes 0 ·

Hi @AsjadButt-2119,

giving a maping type error

Can you share the StudyClass and StudyClassDto code? Perhaps the issue relates the AppUserId and TeacherId properties, check their data type, whether you are using the same type? Then, try to use the same type or you might need to convert the data type when mapping data.



0 Votes 0 ·

0 Answers