2013-12-15 70 views
8

從這裏的類似問題我在這裏讀到AutoMapper曾經是區分大小寫的,但現在不區分大小寫。我希望區分大小寫 - 看不出有什麼方法可以改變這一點,而其他問題都沒有。Re顯示瞭如何去做(我確實看過)。任何想法的人?Automapper - 需要區分大小寫

感謝

+0

有沒有什麼理由在創建地圖時不能使用'.ForMember'? –

+0

我不相信我可以 - 地圖是由T4模板生成的,它只是遍歷列。我遇到的問題是,我改名爲導航設備,並錯誤地將它命名爲常規屬性(雖然情況不同)。通過設置CLSCompliant(true)並將該警告提升爲錯誤,我現在得到的編譯錯誤總比沒有好。實際上現在我正在寫這個,我想我實際上更喜歡使AutoMapper區分大小寫。謝謝Ray – RBrowning99

回答

0

的關閉我能找到的就是命名約定的配置:https://github.com/AutoMapper/AutoMapper/wiki/Configuration#naming-conventions

在配置文件或映射器級別,您可以指定源和目的地命名約定:

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

或者:

public class OrganizationProfile : Profile 
{ 
    public OrganizationProfile() 
    { 
    SourceMemberNamingConvention = new LowerUnderscoreNamingConvention(); 
    DestinationMemberNamingConvention = new PascalCaseNamingConvention(); 
    //Put your CreateMap... Etc.. here 
    } 
}