Skip to content

Instantly share code, notes, and snippets.

@darrencauthon
Created June 20, 2011 19:53
Show Gist options
  • Save darrencauthon/1036421 to your computer and use it in GitHub Desktop.
Save darrencauthon/1036421 to your computer and use it in GitHub Desktop.
AutoMapperAssist example
private class ProductViewMapper : Mapper<Product, ProductView>
{
public override void DefineMap(IConfiguration configuration)
{
configuration.CreateMap<Product, ProductView>()
.ForMember(dest => dest.Name, opt => opt.MapFrom(orig => orig.Name + "WHOOPS"));
}
}
@darrencauthon
Copy link
Author

The IConfiguration argument to DefineMap is AutoMapper's, so you can create any type of mapping you want.

Sometimes I use it to create mappings for child objects, if I have complex trees.

@JasonMore
Copy link

Right, I've used automapper on another project, but found the assist in nuget. Thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment