From a8f009b3073d13373f1e18354674fb20c77a15e5 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 10 Aug 2022 17:45:39 +0800 Subject: [PATCH] Update CodeFirst.NoExistLogic --- Src/Asp.Net/SqlSugar/Realization/Dm/CodeFirst/DmCodeFirst.cs | 4 ++++ .../SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs | 4 ++++ .../Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs | 4 ++++ .../SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Realization/Dm/CodeFirst/DmCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/Dm/CodeFirst/DmCodeFirst.cs index 15427e1c9..bd1f10548 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Dm/CodeFirst/DmCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Dm/CodeFirst/DmCodeFirst.cs @@ -19,6 +19,10 @@ namespace SqlSugar DbColumnInfo dbColumnInfo = this.EntityColumnToDbColumn(entityInfo, tableName, item); columns.Add(dbColumnInfo); } + if (entityInfo.IsCreateTableFiledSort) + { + columns = columns.OrderBy(c => c.CreateTableFieldSort).ToList(); + } } this.Context.DbMaintenance.CreateTable(tableName, columns,true); } diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs index b8d2621a5..1b2652dbb 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs @@ -25,6 +25,10 @@ namespace SqlSugar DbColumnInfo dbColumnInfo = this.EntityColumnToDbColumn(entityInfo, tableName, item); columns.Add(dbColumnInfo); } + if (entityInfo.IsCreateTableFiledSort) + { + columns = columns.OrderBy(c => c.CreateTableFieldSort).ToList(); + } } this.Context.DbMaintenance.CreateTable(tableName, columns,true); } diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs index f3e2cc4e8..0b4e5f636 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs @@ -29,6 +29,10 @@ namespace SqlSugar DbColumnInfo dbColumnInfo = this.EntityColumnToDbColumn(entityInfo, tableName, item); columns.Add(dbColumnInfo); } + if (entityInfo.IsCreateTableFiledSort) + { + columns = columns.OrderBy(c => c.CreateTableFieldSort).ToList(); + } } columns = columns.OrderBy(it => it.IsPrimarykey ? 0 : 1).ToList(); this.Context.DbMaintenance.CreateTable(tableName, columns,true); diff --git a/Src/Asp.Net/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs index aa9a4225c..7716cb898 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs @@ -103,6 +103,10 @@ namespace SqlSugar DbColumnInfo dbColumnInfo = this.EntityColumnToDbColumn(entityInfo, tableName, item); columns.Add(dbColumnInfo); } + if (entityInfo.IsCreateTableFiledSort) + { + columns = columns.OrderBy(c => c.CreateTableFieldSort).ToList(); + } } this.Context.DbMaintenance.CreateTable(tableName, columns,true); }