mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
-
This commit is contained in:
@@ -102,14 +102,40 @@ namespace SqlSugar
|
||||
#region Primary key
|
||||
private static void SetColumns(EntityInfo result)
|
||||
{
|
||||
foreach (var item in result.Type.GetProperties())
|
||||
foreach (var property in result.Type.GetProperties())
|
||||
{
|
||||
EntityColumnInfo column = new EntityColumnInfo();
|
||||
column.PropertyName = item.Name;
|
||||
column.PropertyInfo = item;
|
||||
var isVirtual = property.GetGetMethod().IsVirtual;
|
||||
if (isVirtual) continue;
|
||||
var sugarColumn = property.GetCustomAttributes(typeof(SugarColumn), true)
|
||||
.Where(it => it is SugarColumn)
|
||||
.Select(it => (SugarColumn)it)
|
||||
.Where(it => it.ColumnName.IsValuable())
|
||||
.FirstOrDefault();
|
||||
column.DbTableName = result.DbTableName;
|
||||
column.EnitytName = result.EntityName;
|
||||
column.PropertyName = property.Name;
|
||||
if (sugarColumn.IsNullOrEmpty())
|
||||
{
|
||||
column.DbColumnName = property.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sugarColumn.IsIgnore == false)
|
||||
{
|
||||
column.DbColumnName = sugarColumn.ColumnName.IsNullOrEmpty() ? property.Name : sugarColumn.ColumnName;
|
||||
column.IsPrimarykey = sugarColumn.IsPrimaryKey;
|
||||
column.IsIdentity = sugarColumn.IsIdentity;
|
||||
column.ColumnDescription = sugarColumn.ColumnDescription;
|
||||
}
|
||||
else {
|
||||
column.IsIgnore = true;
|
||||
}
|
||||
}
|
||||
result.Columns.Add(column);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,8 @@ namespace SqlSugar
|
||||
public bool IsNullable { get; set; }
|
||||
public bool IsIdentity { get; set; }
|
||||
public bool IsPrimarykey { get; set; }
|
||||
public string EnitytName { get; set; }
|
||||
public string DbTableName { get; set; }
|
||||
public bool IsIgnore { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user