我们有惯例将snake-case db列转换为我们实体中的pascal case:
Map(x => x.ProjectName).Column("project_name");
映射总是这样。我们怎样才能告诉FNH做这项工作而不是全部输入?
答案 0 :(得分:0)
实施IPropertyConvention
并使用
// in Apply (maybe filter out some special cases)
instance.Column(ToSnakeCase(instance.Name));
private string ToSnakeCase(string name)
{
var result = new Stringbuilder(name.Length);
for (int i = 0; i < name.Length; i++)
{
if (i > 0 && char.IsUpper(name[i]))
result.Append('_').Append(char.ToLower(name[i]));
else
result.Append(char.ToLower(name[i]));
}
return result.ToString();
}