Reputation: 71198
If for example I have something like this:
Mapper.CreateMap<Foo,FooDto>()
.ForMemeber( ...;
and I have
class Bar
{
public Foo Foo { get; set; }
}
class BarDto
{
public FooDto Foo { get; set; }
}
than I have to repeat the mapping logic for Foo to FooDto again:
Mapper.CreateMap<Bar,BarDto>()
.ForMemeber(...
At the moment I use Mapper.Map inside a ValueResolver but I think that there could be a better way
Upvotes: 0
Views: 726
Reputation: 26765
You shouldn't have to re-do the Foo/FooDto mapping logic. Any time AutoMapper finds the Foo/FooDto pair, whether it's in an array of values, dictionary, collection, child member or whatever, that Foo/FooDto configuration will be used. AutoMapper doesn't care where the type pair is found.
Upvotes: 2