2016-10-29 1 views
1

私は次のテストが失敗すると予想しますが、そうではありません。大文字と小文字を区別するようにAutoMapperを設定するにはどうすればよいですか?AutoMapperを大文字と小文字を区別するように設定するには?

public class AutomapperTests 
{ 
    [Fact] 
    public void CaseSensitiveTest() 
    { 
     Mapper.Initialize(cfg => cfg.AddMemberConfiguration().AddName<CaseSensitiveName>()); 

     Mapper.Initialize(cfg => cfg.CreateMap<Source, Destination>()); 

     Mapper.AssertConfigurationIsValid(); 
    } 

    public class Source 
    { 
     public int Foo { get; set; } 
    } 

    public class Destination 
    { 
     public int FoO { get; set; } 
    } 
} 

私はAutoMapperのバージョン5.1.1を使用しています。

+0

[Automapper - 大文字小文字を区別する]の複製(http://stackoverflow.com/questions/20600081/automapper-want-case-sensitive) – Operatorius

+0

@Operatorius私は既に私の記事を掲載する前に他の質問を見てきましたが、問題は本当の答えがないということです。適用されない(または適用されない)ものと3つ目のリンクがないものへのリンクは2つだけです。 –

答えて

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 
    } 
} 
関連する問題