我将尝试使用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.
我错过了什么?我的映射有误吗?它似乎试图使用我不想使用的函数重载。