我正在尝试使用 Automapper 进行映射
这是我当前的映射:
Mapper.CreateMap(Of NameAddress, PersonalDetails)() _
.ForMember(Function(dest) dest.Forenames, Function(opt) opt.MapFrom(Function(src) src.Forename)) _
.ForMember(Function(dest) dest.TelephoneNumber, Function(opt) opt.MapFrom(Function(src) src.TelephoneNo1)) _
.ForMember(Function(dest) dest.MobileNumber, Function(opt) opt.MapFrom(Function(src) src.MobilePhoneNo)) _
.ForMember(Function(dest) dest.NationalInsuranceNumber, Function(opt) opt.MapFrom(Function(src) src.NINo)) _
.ForMember(Function(dest) dest.DateOfBirth, Function(opt) opt.MapFrom(Function(src) src.BirthDate))
因此,我想从 NameAddress 源对象映射到 PersonalDetails 目标对象。源和目标上的其余属性是相同的,因此没有明确定义映射。
但是,当我尝试使用此映射进行编译时,会出现以下编译时错误。
Overload resolution failed because no accessible 'ForMember' can be called with these arguments:
'Public Function ForMember(name As String, memberOptions As System.Action(Of AutoMapper.IMemberConfigurationExpression(Of Infrastructure.NameAddress))) As AutoMapper.IMappingExpression(Of Infrastructure.NameAddress, Core.TaxiLicensing.PersonalDetails)': Lambda expression cannot be converted to 'String' because 'String' is not a delegate type.
'Public Function ForMember(name As String, memberOptions As System.Action(Of AutoMapper.IMemberConfigurationExpression(Of Infrastructure.NameAddress))) As AutoMapper.IMappingExpression(Of Infrastructure.NameAddress, Core.TaxiLicensing.PersonalDetails)': Expression does not produce a value.
'Public Function ForMember(destinationMember As System.Linq.Expressions.Expression(Of System.Func(Of Core.TaxiLicensing.PersonalDetails, Object)), memberOptions As System.Action(Of AutoMapper.IMemberConfigurationExpression(Of Infrastructure.NameAddress))) As AutoMapper.IMappingExpression(Of Infrastructure.NameAddress, Core.TaxiLicensing.PersonalDetails)': Expression does not produce a value.
我错过了什么?我的映射不正确吗?它似乎正在尝试使用我不打算使用的函数的重载。