mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update codefirst decimal default value
This commit is contained in:
parent
45bc377952
commit
416200e032
@ -11,8 +11,9 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
|
||||||
var db = NewUnitTest.Db;
|
var db = NewUnitTest.Db;
|
||||||
var id=db.Insertable(new Order() { CreateTime = DateTime.Now, Name = "a", Price = 111, CustomId = 1 }).ExecuteReturnIdentity();
|
var id=db.Insertable(new Order() { CreateTime = DateTime.Now, Name = "a", Price =Convert.ToDecimal( 111.00) , CustomId = 1 }).ExecuteReturnIdentity();
|
||||||
var data = db.GetSimpleClient<Order>().GetById(id);
|
var data = db.GetSimpleClient<Order>().GetById(id);
|
||||||
var x=db.Storageable(data).WhereColumns(it=>it.Price).ToStorage();
|
var x=db.Storageable(data).WhereColumns(it=>it.Price).ToStorage();
|
||||||
Check.Exception(x.UpdateList.Count == 0, "unit error");
|
Check.Exception(x.UpdateList.Count == 0, "unit error");
|
||||||
|
@ -395,6 +395,14 @@ namespace SqlSugar
|
|||||||
public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
||||||
{
|
{
|
||||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||||
|
foreach (var item in columns)
|
||||||
|
{
|
||||||
|
if (item.DataType == "decimal" && this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer && item.DecimalDigits == 0 && item.Length == 0)
|
||||||
|
{
|
||||||
|
item.DecimalDigits = 4;
|
||||||
|
item.Length = 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
string sql = GetCreateTableSql(tableName, columns);
|
string sql = GetCreateTableSql(tableName, columns);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
if (isCreatePrimaryKey)
|
if (isCreatePrimaryKey)
|
||||||
|
Loading…
Reference in New Issue
Block a user