Below is the Automapping profile. An error is thrown on the destination Id
being of the wrong input format.
The destination Id
property is not even being mapped to.
public class AspGetUserLoginReturnModelToSRSDLUserLoginModel : Profile
{
public AspGetUserLoginReturnModelToSRSDLUserLoginModel()
{
CreateMap<asp_GetUserLoginReturnModel, SRSDLUserLoginModel>()
.ForMember(dest => dest.UserPassword, opt => opt.MapFrom(src => src.PasswordHash))
.ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.Id)
;
}
}
Now the destination class SRSDLUserLoginModel
is derived from a base class that has a public accessor named Id
which is type of nullable long
.
The source Id
property used above is of type string
.
As the code shown above the source Id
is mapped to the destination UserId
property.
But Automapper is mapping the source Id
to the destination's based classes Id
property.
WHY IS THIS HAPPENING?
The code is straight forward and there is nothing new trying to be accomplished. It Automapper like most everything other packages that I have work with?
In the full/classic .NET framework, the packages worked fine, but in .NET Core those packages just suck?
// source class
public partial class asp_GetUserLoginReturnModel
{
public string Id { get; set; }
}
// destination classes
public class SRSDLUserLoginModel: SRSDLModel, ISRSDLUserLoginModel
{
public string UserId { get; set; }
public string UserPassword { get; set; }
// [...]
}
public class SRSDLModel : ISRSDLModel
{
public long? Id { get; set; }
// [...]
}