Automapper: how to ignore a member in VB.NET

I use Automapper in a VB.NET project and try to ignore it. I see how to do this in C #, but not in VB.NET. Does anyone have a quick example of using the ForMember method.

Thank,

Floor

+3
source share
2 answers

Here is how you do it :)

Mapper.CreateMap(Of incomingModel, outgoingModel)().ForMember(Function(x) x.FieldToIgnore, Sub(y) y.Ignore())

The thing that is important and probably what messed you up is the Sub instead of the function for the second part.

this also only works in vs2010. older versions you cannot do.

+9
source

Now (AutoMapper 2.0) there is an IgnoreMap attribute.

+1
source

Source: https://habr.com/ru/post/1796414/


All Articles