forked from AutoMapper/AutoMapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
Calvin Rodo edited this page Jul 4, 2013
·
3 revisions
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>();
});
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();
}
}