0

I'm using Mapster 5.3.1 with DI in EF Core 3.1 ... and I have a question.. is there a way to ignore all null values in source member during mapping when both members are IEnumerable and both have identical structure.

var tSource = (IEnumerable) var tDestination = (IEnumerable)

_mapper.Map(tSource, tDestination)

If tSource have a null value I don't want to that value in tDestination.

I hope you guys can help me.

thanks

1 Answers1

0

You can ignore null property using IgnoreNullVaules. https://github.com/MapsterMapper/Mapster/wiki/Shallow-merge#copy-vs-merge

  • Thanks your time..I had already read that but i'm still getting null values at destination – user13533969 May 18 '20 at 22:05
  • I put this at Startup: TypeAdapterConfig.GlobalSettings.Default.PreserveReference(true); Configure: TypeAdapterConfig .NewConfig() .IgnoreNullValues(true); Controller: _mapper.Map(dtoGetLinea, _entity) Where tSource = IEnumerable and tDestination = IEnumerable Did I miss something? – user13533969 May 18 '20 at 22:43