Automapper Constructor Parameters

513 Views Asked by At

I've just started using this and immediately ran into a problem mapping a parameter to a a constructor parameter.

I've tried every example I can find on SO but none seem to work and the documentation doesn't mention this feature as far as I can see.

The examples show:

Mapper.CreateMap<UserProfile, UserProfileModel>().ConstructUsing(x => new UserProfileModel(x.Id);

I can't figure out the syntax to get access to the Id property on the UserProfile object.

Another example shows:

Mapper.CreateMap<TypeOneDto, TypeOne>().ConstructUsing((Func<ResolutionContext, TypeOne>) (r => new TypeOne()));

On using any of these lambdas I just have access to the ResolutionContext not the parent object?

Any Ideas?

0

There are 0 best solutions below