This commit is contained in:
sunkaixuan
2017-10-21 16:06:12 +08:00
parent a2812eae8a
commit 36adba37ae

View File

@@ -76,7 +76,7 @@ namespace SqlSugar
}
public string GetDbColumnName<T>(string propertyName)
{
var isAny=this.GetEntityInfo<T>().Columns.Any(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
var isAny = this.GetEntityInfo<T>().Columns.Any(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
Check.Exception(!isAny, "Property " + propertyName + " is Invalid");
var typeName = typeof(T).Name;
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0) return propertyName;
@@ -102,7 +102,7 @@ namespace SqlSugar
return typeof(T).GetProperties().First(it => it.Name == propertyName);
}
#region Primary key
private static void SetColumns(EntityInfo result)
private void SetColumns(EntityInfo result)
{
foreach (var property in result.Type.GetProperties())
{
@@ -141,6 +141,18 @@ namespace SqlSugar
column.IsIgnore = true;
}
}
if (this.Context.MappingColumns.HasValue())
{
var golbalMappingInfo = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName.Equals(result.EntityName, StringComparison.CurrentCultureIgnoreCase) && it.PropertyName == column.PropertyName);
if (golbalMappingInfo != null)
column.DbColumnName = golbalMappingInfo.DbColumnName;
}
if (this.Context.IgnoreColumns.HasValue())
{
var golbalMappingInfo = this.Context.IgnoreColumns.FirstOrDefault(it => it.EntityName.Equals(result.EntityName, StringComparison.CurrentCultureIgnoreCase) && it.PropertyName == column.PropertyName);
if (golbalMappingInfo != null)
column.IsIgnore = true;
}
result.Columns.Add(column);
}
}