tags:

views:

76

answers:

1

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

+1  A: 

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.

Jimmy Bogard