Merge branch 'master' of gitee.com:dotnetchina/SqlSugar

This commit is contained in:
sunkaixuan 2022-07-14 19:46:52 +08:00
commit 849ab706f6
6 changed files with 20 additions and 3 deletions

View File

@ -263,6 +263,10 @@ namespace SqlSugar
DbColumnInfo dbColumnInfo = EntityColumnToDbColumn(entityInfo, tableName, item); DbColumnInfo dbColumnInfo = EntityColumnToDbColumn(entityInfo, tableName, item);
columns.Add(dbColumnInfo); columns.Add(dbColumnInfo);
} }
if (entityInfo.IsCreateTableFiledSort)
{
columns = columns.OrderBy(c => c.CreateTableFieldSort).ToList();
}
} }
this.Context.DbMaintenance.CreateTable(tableName, columns, true); this.Context.DbMaintenance.CreateTable(tableName, columns, true);
} }
@ -433,7 +437,8 @@ namespace SqlSugar
DefaultValue = item.DefaultValue, DefaultValue = item.DefaultValue,
ColumnDescription = item.ColumnDescription, ColumnDescription = item.ColumnDescription,
Length = item.Length, Length = item.Length,
DecimalDigits = item.DecimalDigits DecimalDigits = item.DecimalDigits,
CreateTableFieldSort = item.CreateTableFieldSort
}; };
GetDbType(item, propertyType, result); GetDbType(item, propertyType, result);
return result; return result;

View File

@ -36,6 +36,7 @@ namespace SqlSugar
result.TableDescription = sugarTable.TableDescription.ToSqlFilter(); result.TableDescription = sugarTable.TableDescription.ToSqlFilter();
result.IsDisabledUpdateAll = sugarTable.IsDisabledUpdateAll; result.IsDisabledUpdateAll = sugarTable.IsDisabledUpdateAll;
result.IsDisabledDelete = sugarTable.IsDisabledDelete; result.IsDisabledDelete = sugarTable.IsDisabledDelete;
result.IsCreateTableFiledSort = sugarTable.IsCreateTableFiledSort;
} }
var indexs = type.GetCustomAttributes(typeof(SugarIndexAttribute)); var indexs = type.GetCustomAttributes(typeof(SugarIndexAttribute));
if (indexs != null && indexs.Any()) if (indexs != null && indexs.Any())
@ -284,7 +285,7 @@ namespace SqlSugar
column.IsArray = sugarColumn.IsArray; column.IsArray = sugarColumn.IsArray;
column.IsTreeKey = sugarColumn.IsTreeKey; column.IsTreeKey = sugarColumn.IsTreeKey;
column.SqlParameterDbType = sugarColumn.SqlParameterDbType; column.SqlParameterDbType = sugarColumn.SqlParameterDbType;
column.CreateTableFieldSort = sugarColumn.CreateTableFieldSort;
if (sugarColumn.IsJson && String.IsNullOrEmpty(sugarColumn.ColumnDataType)) if (sugarColumn.IsJson && String.IsNullOrEmpty(sugarColumn.ColumnDataType))
{ {
if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL) if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)

View File

@ -24,5 +24,6 @@ namespace SqlSugar
public bool IsArray { get; set; } public bool IsArray { get; set; }
internal bool IsJson { get; set; } internal bool IsJson { get; set; }
public bool? IsUnsigned { get; set; } public bool? IsUnsigned { get; set; }
public int CreateTableFieldSort { get; set; }
} }
} }

View File

@ -39,5 +39,6 @@ namespace SqlSugar
public bool IsArray { get; set; } public bool IsArray { get; set; }
public Type UnderType { get; set; } public Type UnderType { get; set; }
public Navigate Navigat { get; set; } public Navigate Navigat { get; set; }
public int CreateTableFieldSort { get; set; }
} }
} }

View File

@ -18,5 +18,6 @@ namespace SqlSugar
public bool IsDisabledDelete { get; set; } public bool IsDisabledDelete { get; set; }
public bool IsDisabledUpdateAll { get; set; } public bool IsDisabledUpdateAll { get; set; }
public List<SugarIndexAttribute> Indexs { get; set; } public List<SugarIndexAttribute> Indexs { get; set; }
public bool IsCreateTableFiledSort { get; set; }
} }
} }

View File

@ -13,7 +13,7 @@ namespace SqlSugar
public string TableDescription { get; set; } public string TableDescription { get; set; }
public bool IsDisabledDelete { get; set; } public bool IsDisabledDelete { get; set; }
public bool IsDisabledUpdateAll { get; set; } public bool IsDisabledUpdateAll { get; set; }
public bool IsCreateTableFiledSort { get; set; }
public SugarTable(string tableName) { public SugarTable(string tableName) {
this.TableName = tableName; this.TableName = tableName;
} }
@ -29,6 +29,13 @@ namespace SqlSugar
this.TableDescription = tableDescription; this.TableDescription = tableDescription;
this.IsDisabledDelete = isDisabledDelete; this.IsDisabledDelete = isDisabledDelete;
} }
public SugarTable(string tableName, string tableDescription, bool isDisabledDelete, bool isCreateTableFieldSort)
{
this.TableName = tableName;
this.TableDescription = tableDescription;
this.IsDisabledDelete = isDisabledDelete;
this.IsCreateTableFiledSort = isCreateTableFieldSort;
}
} }
[AttributeUsage(AttributeTargets.Property , Inherited = true)] [AttributeUsage(AttributeTargets.Property , Inherited = true)]
public class SugarColumn : Attribute public class SugarColumn : Attribute
@ -198,6 +205,7 @@ namespace SqlSugar
} }
public object SqlParameterDbType { get; set; } public object SqlParameterDbType { get; set; }
public int CreateTableFieldSort { get; set; }
} }