C# AutoMapper 2.1.267.0不映射简单int?财产
我有以下课程 资料来源:C# AutoMapper 2.1.267.0不映射简单int?财产,c#,automapper,automapper-2,C#,Automapper,Automapper 2,我有以下课程 资料来源: public class NewBusinessSubmission { //other properties public int? TermTypeId { get; set; } } 目的地: NewBusinessSubmission类继承自如下所示的PolicyTransaction类(是的,它是VB.NET): 关于此属性未正确映射的原因,您有什么想法吗 谢谢。您使用的是哪个版本的AutoMapper?更新了问题标题。我使用的
public class NewBusinessSubmission
{
//other properties
public int? TermTypeId { get; set; }
}
目的地:
NewBusinessSubmission类继承自如下所示的PolicyTransaction类(是的,它是VB.NET):
关于此属性未正确映射的原因,您有什么想法吗
谢谢。您使用的是哪个版本的AutoMapper?更新了问题标题。我使用的是2.1.267.0
<System.Serializable()> Public MustInherit Class PolicyTransaction
Inherits Framework2.BusinessBase(Of PolicyTransaction)
Implements IDisposable
...........
Public Property TermTypeId() As Nullable(Of Integer)
Get
CanReadProperty(True)
If Not _PolicyTermsDataRow.IsTermTypeIdNull Then
Return Me._PolicyTermsDataRow.TermTypeId
End If
End Get
Set(ByVal value As Nullable(Of Integer))
If Nullable(Of Integer).Equals(value, Me.TermTypeId) Then Exit Property
CanWriteProperty(True)
If value.HasValue Then
Me._PolicyTermsDataRow.TermTypeId = value.Value
Else
Me._PolicyTermsDataRow.SetTermTypeIdNull()
End If
AfterTermTypeIdChanged()
Me.PropertyHasChanged()
End Set
End Property
...........
End Class
Mapper.CreateMap<NewBusinessSubmission, NewBusiness>()
.ForMember(x => x.PolicyTxnNum, opt => opt.Ignore())
.ForMember(x => x.ContactProducerLicId, opt => opt.Ignore())
.ForMember(x => x.PolicyNames, opt => opt.Ignore())
.ForMember(x => x.PolicyExp, opt => opt.Ignore());
Mapper.CreateMap<NewBusinessSubmission, NewBusiness>()
.ForMember(x => x.PolicyTxnNum, opt => opt.Ignore())
.ForMember(x => x.ContactProducerLicId, opt => opt.Ignore())
.ForMember(x => x.PolicyNames, opt => opt.Ignore())
.ForMember(x => x.PolicyExp, opt => opt.Ignore())
.ForMember(x => x.TermTypeId, opt => opt.MapFrom(x => x.TermTypeId));
var newBusiness = Mapper.Map<NewBusinessSubmission, NewBusiness>(newBusinessSubmission);
newBusinessInstance.TermTypeId = newBusinessSubmissionInstance.TermTypeId;