Ignoring most of members

640 views
Skip to first unread message

CNemo

unread,
Mar 18, 2009, 10:34:47 AM3/18/09
to AutoMapper-users
I have situation where I need to map my dto to a couple of domain
objects.
Most of the properties populated from one object and only few from
another one.
AM works fine in situation with first object, because naming is
consistent.

But with second object I have to do a lot of Ignore() mapping.
Is there proven approach for such situations?

I thought to use ForAllMembers() with Ignore() and then map only when
needed but it doesn't work.

Any ideas?

Jimmy Bogard

unread,
Mar 19, 2009, 7:52:57 PM3/19/09
to automapp...@googlegroups.com
For the next release, we're still looking at providing base class configuration, where you can configure default behavior for some base type.  Until then, you're still looking at doing a lot of Ignore().

Another option is to supply an extension method to do the common configuration.  I'll post an update here with an example.

kiran

unread,
Apr 7, 2009, 1:04:26 PM4/7/09
to AutoMapper-users
Is this implemented in the new release? Is it now possible to
configure default behavior for the base type?

Can you provide an example to ignore most of the members.?

Jimmy Bogard

unread,
Apr 17, 2009, 9:17:32 AM4/17/09
to automapp...@googlegroups.com
I committed a sample last night that shows you how to do this.  The trick is to combine extension methods + generic constraints.  It lets you target domain-specific configuration for very specific type families, without cluttering up the rest of the interface.

Check out the "ProvidingCommonBaseClassConfiguration" class in the samples project, it should do what ya need.
Reply all
Reply to author
Forward
0 new messages