I have an issue with uppercase underscore mappings.
Data Class have property like => USER_ID
Dto class property => UserId
If a change it to Userİd it's working.
How could i do mapping without formember method ? Thanks
My initializer :
cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
Edit:
I solved it for now. It worked for USER_ID => UserId
Main topic : Automapper: How to leverage a custom INamingConvention?
Solution with basic if :
public class UpperUnderscoreNamingConvention : INamingConvention
{
private readonly Regex _splittingExpression = new Regex(@"[\p{Lu}0-9]+(?=_?)");
public Regex SplittingExpression { get { return _splittingExpression; } }
public string SeparatorCharacter { get { return "_"; } }
public string ReplaceValue(Match match)
{
return match.Value.Equals("I") ? "ı" : match.Value.ToLowerInvariant();
}
}
config :
Mapper.Initialize(cfg =>
{
cfg.SourceMemberNamingConvention = new UpperUnderscoreNamingConvention();
cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
});