Skip to content

Commit 3f8aa06

Browse files
committed
fix
1 parent 4d54771 commit 3f8aa06

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/Mapster.Tests/WhenMappingRecordRegression.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ public void RecorsTypeSupporIgnoreIfIsCorrect()
640640
{
641641
var config = new TypeAdapterConfig();
642642
config.NewConfig<PaymentDTO771, PaymentDTO771>()
643+
.IgnoreNullValues(true)
643644
.IgnoreIf((src, dest) => src.CVV == "442", nameof(PaymentDTO771.CVV));
644645
config.NewConfig<TestRecordY, TestRecordY>()
645646
.IgnoreIf((src, dest) => src.X == 42, dest => dest.Y);

src/Mapster/Adapters/RecordTypeAdapter2.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ protected override Expression CreateBlockExpression(Expression source, Expressio
173173
Dictionary<LambdaExpression, Tuple<List<Expression>, Expression>>? conditions = null;
174174
foreach (var member in members)
175175
{
176+
177+
if (arg.Settings.IgnoreNullValues == false)
178+
{
179+
if (member.UseDestinationValue || member.Ignore.Condition != null) ;
180+
else
181+
continue;
182+
}
183+
184+
185+
176186
var destMember = arg.MapType == MapType.MapToTarget || member.UseDestinationValue
177187
? member.DestinationMember.GetExpression(result)
178188
: null;

0 commit comments

Comments
 (0)