I have the following classes
Source:
public class NewBusinessSubmission
{
//other properties
public int? TermTypeId { get; set; }
}
Destination:
NewBusinessSubmission class inherits from the PolicyTransaction class shown below (yes it is VB.NET):
<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
Mapping Configuration below does not set the TermTypeId:
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());
This one does not work either:
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));
I call Map like this:
var newBusiness = Mapper.Map<NewBusinessSubmission, NewBusiness>(newBusinessSubmission);
All the other properties that have similar code in the Set() method map correctly and I can also manually map TermTypeId like this:
newBusinessInstance.TermTypeId = newBusinessSubmissionInstance.TermTypeId;
Any ideas as to why this property is not mapped correctly?
Thanks.