diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs index ebb107167..90c43d84f 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs @@ -302,9 +302,9 @@ namespace SqlSugar this.Context.Ado.ExecuteCommand(sql); return true; } - public virtual bool CreateIndex(string tableName, string[] columnNames) + public virtual bool CreateIndex(string tableName, string[] columnNames, bool isUnique=false) { - string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames)); + string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames), isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } diff --git a/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs b/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs index a2c346430..d16e67d68 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs @@ -193,6 +193,7 @@ namespace SqlSugar column.NoSerialize = sugarColumn.NoSerialize; column.DefaultValue = sugarColumn.DefaultValue; column.IndexGroupNameList = sugarColumn.IndexGroupNameList; + column.UIndexGroupNameList = sugarColumn.UIndexGroupNameList; column.IsOnlyIgnoreUpdate = sugarColumn.IsOnlyIgnoreUpdate; column.IsArray = sugarColumn.IsArray; } diff --git a/Src/Asp.Net/SqlSugar/Entities/EntityColumnInfo.cs b/Src/Asp.Net/SqlSugar/Entities/EntityColumnInfo.cs index fa9c45279..2ef141f4b 100644 --- a/Src/Asp.Net/SqlSugar/Entities/EntityColumnInfo.cs +++ b/Src/Asp.Net/SqlSugar/Entities/EntityColumnInfo.cs @@ -33,6 +33,7 @@ namespace SqlSugar public bool IsJson { get; set; } public bool NoSerialize { get; set; } public string[] IndexGroupNameList { get; set; } + public string[] UIndexGroupNameList { get; set; } public bool IsArray { get; set; } } } diff --git a/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs b/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs index 994390132..0603d4136 100644 --- a/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs +++ b/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs @@ -171,6 +171,8 @@ namespace SqlSugar set { _IndexGroupNameList = value; } } + public string[] UIndexGroupNameList { get; set; } + private bool _IsArray; public bool IsArray { diff --git a/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs index 0cb175aca..b16394655 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs @@ -28,7 +28,7 @@ namespace SqlSugar #region DDL bool AddDefaultValue(string tableName,string columnName,string defaultValue); - bool CreateIndex(string tableName, string [] columnNames); + bool CreateIndex(string tableName, string [] columnNames, bool isUnique=false); bool DropTable(string tableName); bool TruncateTable(string tableName); bool TruncateTable(); diff --git a/Src/Asp.Net/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs index f87be33f9..97e46bee0 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs @@ -62,7 +62,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0}({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0}({1})"; } } protected override string AddDefaultValueSql @@ -271,9 +271,9 @@ namespace SqlSugar } return base.AddColumn(tableName, columnInfo); } - public override bool CreateIndex(string tableName, string[] columnNames) + public override bool CreateIndex(string tableName, string[] columnNames, bool isUnique = false) { - string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it => (it + "abc").Substring(0, 3)))); + string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it => (it + "abc").Substring(0, 3))), isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } @@ -348,11 +348,11 @@ namespace SqlSugar return GetColumnInfosByTableName(tableName); else return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, - () => - { - return GetColumnInfosByTableName(tableName); + () => + { + return GetColumnInfosByTableName(tableName); - }); + }); } private List GetColumnInfosByTableName(string tableName) @@ -360,7 +360,7 @@ namespace SqlSugar string sql = "select * from " + SqlBuilder.GetTranslationTableName(tableName) + " WHERE 1=2 "; var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; this.Context.Ado.IsEnableLogEvent = false; - using (DbDataReader reader = (DbDataReader)this.Context.Ado.GetDataReader(sql)) + using(DbDataReader reader = (DbDataReader) this.Context.Ado.GetDataReader(sql)) { this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; List result = new List(); @@ -371,8 +371,8 @@ namespace SqlSugar { TableName = tableName, DataType = row["DataType"].ToString().Replace("System.", "").Trim(), - IsNullable = (bool)row["AllowDBNull"], - IsIdentity = (bool)row["IsIdentity"], + IsNullable = (bool) row["AllowDBNull"], + IsIdentity = (bool) row["IsIdentity"], ColumnDescription = GetFieldComment(tableName, row["ColumnName"].ToString()), DbColumnName = row["ColumnName"].ToString(), //DefaultValue = row["defaultValue"].ToString(), @@ -391,32 +391,32 @@ namespace SqlSugar string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); cacheKey = GetCacheKey(cacheKey); return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, - () => - { - var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; - this.Context.Ado.IsEnableLogEvent = false; - string sql = @" select distinct cu.COLUMN_name KEYNAME from user_cons_columns cu, user_constraints au + () => + { + var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; + this.Context.Ado.IsEnableLogEvent = false; + string sql = @" select distinct cu.COLUMN_name KEYNAME from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and au.table_name = '" + tableName.ToUpper() + @"'"; - var pks = this.Context.Ado.SqlQuery(sql); - this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; - return pks; - }); + var pks = this.Context.Ado.SqlQuery(sql); + this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; + return pks; + }); } public string GetTableComment(string tableName) { string cacheKey = "DbMaintenanceProvider.GetTableComment." + tableName; var comments = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, - () => - { - string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME"; - var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; - this.Context.Ado.IsEnableLogEvent = false; - var pks = this.Context.Ado.SqlQuery(sql, new { tableName = tableName.ToUpper() }); - this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; - return pks; - }); + () => + { + string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME"; + var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; + this.Context.Ado.IsEnableLogEvent = false; + var pks = this.Context.Ado.SqlQuery(sql, new { tableName = tableName.ToUpper() }); + this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; + return pks; + }); return comments.HasValue() ? comments.First() : ""; } @@ -424,15 +424,15 @@ namespace SqlSugar { string cacheKey = "DbMaintenanceProvider.GetFieldComment." + tableName; var comments = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, - () => - { - string sql = "SELECT TVNAME AS TableName, COLNAME,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='"+ tableName.ToUpper() + "' ORDER BY TVNAME"; - var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; - this.Context.Ado.IsEnableLogEvent = false; - var pks = this.Context.Ado.SqlQuery(sql); - this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; - return pks; - }); + () => + { + string sql = "SELECT TVNAME AS TableName, COLNAME,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName.ToUpper() + "' ORDER BY TVNAME"; + var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; + this.Context.Ado.IsEnableLogEvent = false; + var pks = this.Context.Ado.SqlQuery(sql); + this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; + return pks; + }); return comments.HasValue() ? comments.First(it => it.DbColumnName.Equals(filedName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : ""; } @@ -462,4 +462,4 @@ namespace SqlSugar } #endregion } -} +} \ No newline at end of file diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index a9039d0be..fced20b03 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -250,7 +250,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0} ({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})"; } } diff --git a/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs index c7d3589b1..38b8db9e7 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs @@ -62,7 +62,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0}({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0}({1})"; } } protected override string AddDefaultValueSql @@ -271,9 +271,9 @@ namespace SqlSugar } return base.AddColumn(tableName,columnInfo); } - public override bool CreateIndex(string tableName, string[] columnNames) + public override bool CreateIndex(string tableName, string[] columnNames, bool isUnique=false) { - string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it=>(it+"abc").Substring(0,3)))); + string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it=>(it+"abc").Substring(0,3))), isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs index 83145e8ac..9c789d4d3 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs @@ -178,7 +178,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0} ({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})"; } } protected override string AddDefaultValueSql diff --git a/Src/Asp.Net/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs index 1518f4a13..b9d9147ec 100644 --- a/Src/Asp.Net/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs @@ -249,7 +249,7 @@ namespace SqlSugar { get { - return "CREATE NONCLUSTERED INDEX Index_{0}_{2} ON {0}({1})"; + return "CREATE {3} NONCLUSTERED INDEX Index_{0}_{2} ON {0}({1})"; } } protected override string AddDefaultValueSql diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs index ebb107167..5177c3229 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs @@ -302,9 +302,9 @@ namespace SqlSugar this.Context.Ado.ExecuteCommand(sql); return true; } - public virtual bool CreateIndex(string tableName, string[] columnNames) + public virtual bool CreateIndex(string tableName, string[] columnNames, bool isUnique = false) { - string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames)); + string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames), isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs index a2c346430..d16e67d68 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs @@ -193,6 +193,7 @@ namespace SqlSugar column.NoSerialize = sugarColumn.NoSerialize; column.DefaultValue = sugarColumn.DefaultValue; column.IndexGroupNameList = sugarColumn.IndexGroupNameList; + column.UIndexGroupNameList = sugarColumn.UIndexGroupNameList; column.IsOnlyIgnoreUpdate = sugarColumn.IsOnlyIgnoreUpdate; column.IsArray = sugarColumn.IsArray; } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/EntityColumnInfo.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/EntityColumnInfo.cs index fa9c45279..2ef141f4b 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/EntityColumnInfo.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/EntityColumnInfo.cs @@ -33,6 +33,7 @@ namespace SqlSugar public bool IsJson { get; set; } public bool NoSerialize { get; set; } public string[] IndexGroupNameList { get; set; } + public string[] UIndexGroupNameList { get; set; } public bool IsArray { get; set; } } } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs index 994390132..0603d4136 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs @@ -171,6 +171,8 @@ namespace SqlSugar set { _IndexGroupNameList = value; } } + public string[] UIndexGroupNameList { get; set; } + private bool _IsArray; public bool IsArray { diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IDbMaintenance.cs index 0cb175aca..b16394655 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Interface/IDbMaintenance.cs @@ -28,7 +28,7 @@ namespace SqlSugar #region DDL bool AddDefaultValue(string tableName,string columnName,string defaultValue); - bool CreateIndex(string tableName, string [] columnNames); + bool CreateIndex(string tableName, string [] columnNames, bool isUnique=false); bool DropTable(string tableName); bool TruncateTable(string tableName); bool TruncateTable(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs index f87be33f9..f69265091 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs @@ -62,7 +62,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0}({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0}({1})"; } } protected override string AddDefaultValueSql @@ -271,9 +271,9 @@ namespace SqlSugar } return base.AddColumn(tableName, columnInfo); } - public override bool CreateIndex(string tableName, string[] columnNames) + public override bool CreateIndex(string tableName, string[] columnNames, bool isUnique = false) { - string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it => (it + "abc").Substring(0, 3)))); + string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it => (it + "abc").Substring(0, 3))), isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs index f26c921bf..76ccfabbc 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs @@ -178,7 +178,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0} ({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})"; } } protected override string AddDefaultValueSql diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index a9039d0be..fced20b03 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -250,7 +250,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0} ({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})"; } } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs index c7d3589b1..38b8db9e7 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs @@ -62,7 +62,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0}({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0}({1})"; } } protected override string AddDefaultValueSql @@ -271,9 +271,9 @@ namespace SqlSugar } return base.AddColumn(tableName,columnInfo); } - public override bool CreateIndex(string tableName, string[] columnNames) + public override bool CreateIndex(string tableName, string[] columnNames, bool isUnique=false) { - string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it=>(it+"abc").Substring(0,3)))); + string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames.Select(it=>(it+"abc").Substring(0,3))), isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs index 83145e8ac..9c789d4d3 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs @@ -178,7 +178,7 @@ namespace SqlSugar { get { - return "CREATE INDEX Index_{0}_{2} ON {0} ({1})"; + return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})"; } } protected override string AddDefaultValueSql diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs index 20716c14e..78ec403de 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs @@ -249,7 +249,7 @@ namespace SqlSugar { get { - return "CREATE NONCLUSTERED INDEX Index_{0}_{2} ON {0}({1})"; + return "CREATE {3} NONCLUSTERED INDEX Index_{0}_{2} ON {0}({1})"; } } protected override string AddDefaultValueSql