Skip to content

Commit

Permalink
IgnoreNonMapped skip RequireDestinationMemberSource
Browse files Browse the repository at this point in the history
  • Loading branch information
DocSvartz committed Jan 23, 2025
1 parent 155a723 commit c9b0a8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Mapster.Tests/WhenIgnoringNonMapped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void Should_Ignore_Non_Mapped()
{
TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig()
.Map(dest => dest.Id, src => src.Id)
.RequireDestinationMemberSource(true)
.IgnoreNonMapped(true)
.Compile();

Expand Down
4 changes: 4 additions & 0 deletions src/Mapster/Adapters/BaseClassAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ src is LambdaExpression lambda

var resolvers = arg.Settings.ValueAccessingStrategies.AsEnumerable();
if (arg.Settings.IgnoreNonMapped == true)
{
arg.Settings.SkipDestinationMemberCheck = true;
resolvers = resolvers.Where(ValueAccessingStrategy.CustomResolvers.Contains);
}

var getter = (from fn in resolvers
from src in sources
select fn(src, destinationMember, arg))
Expand Down

0 comments on commit c9b0a8f

Please sign in to comment.