mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
CodeFirst Entity Add DataType
This commit is contained in:
@@ -16,6 +16,7 @@ namespace OrmTest.Demo
|
|||||||
[SugarColumn(IsNullable = true,Length =10)]
|
[SugarColumn(IsNullable = true,Length =10)]
|
||||||
public string IsOk { get; set; }
|
public string IsOk { get; set; }
|
||||||
public Guid Guid { get; set; }
|
public Guid Guid { get; set; }
|
||||||
|
[SugarColumn(ColumnDataType ="int")]
|
||||||
public decimal Decimal { get; set; }
|
public decimal Decimal { get; set; }
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public DateTime? DateTime { get; set; }
|
public DateTime? DateTime { get; set; }
|
||||||
|
|||||||
@@ -223,7 +223,11 @@ namespace SqlSugar
|
|||||||
ColumnDescription = item.ColumnDescription,
|
ColumnDescription = item.ColumnDescription,
|
||||||
Length = item.Length
|
Length = item.Length
|
||||||
};
|
};
|
||||||
if (propertyType.IsEnum())
|
if (!string.IsNullOrEmpty(item.DataType))
|
||||||
|
{
|
||||||
|
result.DataType = item.DataType;
|
||||||
|
}
|
||||||
|
else if (propertyType.IsEnum())
|
||||||
{
|
{
|
||||||
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(item.Length > 9 ? PubConst.LongType.Name : PubConst.IntType.Name);
|
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(item.Length > 9 ? PubConst.LongType.Name : PubConst.IntType.Name);
|
||||||
}
|
}
|
||||||
@@ -236,6 +240,10 @@ namespace SqlSugar
|
|||||||
|
|
||||||
protected virtual bool IsSamgeType(EntityColumnInfo ec, DbColumnInfo dc)
|
protected virtual bool IsSamgeType(EntityColumnInfo ec, DbColumnInfo dc)
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(ec.DataType))
|
||||||
|
{
|
||||||
|
return ec.DataType != dc.DataType;
|
||||||
|
}
|
||||||
var propertyType = PubMethod.GetUnderType(ec.PropertyInfo);
|
var propertyType = PubMethod.GetUnderType(ec.PropertyInfo);
|
||||||
var properyTypeName = string.Empty;
|
var properyTypeName = string.Empty;
|
||||||
if (propertyType.IsEnum())
|
if (propertyType.IsEnum())
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ namespace SqlSugar
|
|||||||
column.IsNullable = sugarColumn.IsNullable;
|
column.IsNullable = sugarColumn.IsNullable;
|
||||||
column.Length = sugarColumn.Length;
|
column.Length = sugarColumn.Length;
|
||||||
column.OldDbColumnName = sugarColumn.OldColumnName;
|
column.OldDbColumnName = sugarColumn.OldColumnName;
|
||||||
|
column.DataType = sugarColumn.ColumnDataType;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ namespace SqlSugar
|
|||||||
public string EntityName { get; set; }
|
public string EntityName { get; set; }
|
||||||
public string DbTableName { get; set; }
|
public string DbTableName { get; set; }
|
||||||
public bool IsIgnore { get; set; }
|
public bool IsIgnore { get; set; }
|
||||||
|
public string DataType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ namespace SqlSugar
|
|||||||
set { _OldColumnName = value; }
|
set { _OldColumnName = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string _ColumnDataType;
|
||||||
|
public string ColumnDataType
|
||||||
|
{
|
||||||
|
get { return _ColumnDataType; }
|
||||||
|
set { _ColumnDataType = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user