Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoMapper Exclude Fields

Tags:

I'm trying to map one object to another but the object is quite complex. During development, I'd like the ability to either exclude a bunch of fields and get to them one by one or be able to specify to map only fields I want and increase that as each test succeeds.

So:

class         string field1         string field2         string field3 

Now I'd like to map field1, test, fix and then move onto field2 then field3.

Is this possible?

like image 768
griegs Avatar asked Jun 30 '10 05:06

griegs


People also ask

How do I ignore fields in AutoMapper?

So, the AutoMapper Ignore() method is used when you want to completely ignore the property in the mapping. The ignored property could be in either the source or the destination object.

Is AutoMapper faster than manual mapping?

Automapper is considerably faster when mapping a List<T> of objects on . NET Core (It's still slower on full . NET Framework).

Does AutoMapper map private fields?

By default, AutoMapper only recognizes public members. It can map to private setters, but will skip internal/private methods and properties if the entire property is private/internal.


1 Answers

.ForMember(dto => dto.field1, opt => opt.Ignore()); 
like image 189
fulvio Avatar answered Oct 15 '22 00:10

fulvio