Skip to content
Calvin Rodo edited this page Jul 4, 2013 · 3 revisions

Profile Instances

can be used to organize AutoMapper Configuration

public class OrganizationProfile : Profile 
{
  protected override void Configure() 
  {
    //Put your Mapper.CreateMap... Etc.. here
  }

  public override string ProfileName  
  { 
    get { return this.GetType().Name; } 
  } 
}

Initialize the profile like so

Mapper.Initialize(cfg => {
  cfg.AddProfile<OrganizationProfile>();
});

Naming Conventions

You can set the source and destination naming conventions

Mapper.Initialize(cfg =>
  cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
  cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
}

This will map the following properties to each other: property_name -> PropertyName

You can also set this at a per profile level

public class OrganizationProfile : Profile 
{
  protected override void Configure() 
  {
    //Put your Mapper.CreateMap... Etc.. here
    SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
    DestinationMemberNamingConvention = new PascalCaseNamingConvention();
  }
}
Clone this wiki locally