I have the following code in my MappingProfile.cs: public class MappingProfile: Profile { public MappingProfile() {
CreateMap<GraphUserDeltaApiDto, User>().ReverseMap();
}
}
And in my code I'm doing this:
graphClient.CheckforUserDeltas();
var graphDtoUsers = graphClient.UserObjects;
List<User> freshUsers = mapper.Map<List<GraphUserDeltaApiDto>>(graphDtoUsers);
The error I get is:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
HResult=0x80131500 Message=Cannot implicitly convert type 'System.Collections.Generic.List<Core.Application.Contracts.DTOs.GraphUserDeltaApiDto>' to 'System.Collections.Generic.List<Core.Domain.Entities.User>'
I found this post:
Mapping Lists using Automapper
Based on that I tried to change my logic to look like this:
var Users = mapper.Map(List<User>,List<GraphUserDeltaApiDto>>(graphDtoUsers);
var localSave = UpsertO3MWithLatestUserData(Users);
but now i get this error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException HResult=0x80131500 Message=The best overloaded method match for 'AutoMapper.IMapperBase.Map<System.Collections.Generic.List<Core.Domain.Entities.User>,System.Collections.Generic.List<Core.Application.Contracts.DTOs.GraphUserDeltaApiDto>>(System.Collections.Generic.List<Core.Domain.Entities.User>)'
has some invalid arguments Source=System.Linq.Expressions
My understanding is that any fields with the same name will be copied from the source to the destination object. In my case, the source has way more data than the destination.
I'm not sure how to debug this.
Any tips would be appreciated.