From e8bc95906afed24212708bae26a0ec2a31f9f0d4 Mon Sep 17 00:00:00 2001 From: skx <610262374@qq.com> Date: Sat, 16 Jan 2021 18:35:56 +0800 Subject: [PATCH] - --- .../SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs | 8 ++++---- Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs index 567adb98d..ac861cbb0 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs @@ -306,13 +306,13 @@ namespace SqlSugar } public virtual bool CreateIndex(string tableName, string[] columnNames, bool isUnique=false) { - string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames), isUnique ? "UNIQUE" : ""); + string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix, isUnique ? "UNIQUE" : ""); this.Context.Ado.ExecuteCommand(sql); return true; } public virtual bool CreateUniqueIndex(string tableName, string[] columnNames) { - string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames)+"_Unique","UNIQUE" ); + string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix + "_Unique","UNIQUE" ); this.Context.Ado.ExecuteCommand(sql); return true; } @@ -370,7 +370,7 @@ namespace SqlSugar foreach (var item in groups) { var columnNames = indexColumns.Where(it => it.IndexGroupNameList.Any(i => i.Equals(item, StringComparison.CurrentCultureIgnoreCase))).Select(it=>it.DbColumnName).ToArray(); - var indexName = string.Format("Index_{0}_{1}"+this.Context.CurrentConnectionConfig.ConfigId.ObjToString().Replace("-",""),entityInfo.DbTableName, string.Join("_", columnNames)); + var indexName = string.Format("Index_{0}_{1}"+this.Context.CurrentConnectionConfig.IndexSuffix,entityInfo.DbTableName, string.Join("_", columnNames)); if (!IsAnyIndex(indexName)) { CreateIndex(entityInfo.DbTableName, columnNames); @@ -386,7 +386,7 @@ namespace SqlSugar foreach (var item in groups) { var columnNames = uIndexColumns.Where(it => it.UIndexGroupNameList.Any(i => i.Equals(item, StringComparison.CurrentCultureIgnoreCase))).Select(it => it.DbColumnName).ToArray(); - var indexName = string.Format("Index_{0}_{1}_Unique" + this.Context.CurrentConnectionConfig.ConfigId.ObjToString().Replace("-", ""), entityInfo.DbTableName, string.Join("_", columnNames)); + var indexName = string.Format("Index_{0}_{1}_Unique" + this.Context.CurrentConnectionConfig.IndexSuffix, entityInfo.DbTableName, string.Join("_", columnNames)); if (!IsAnyIndex(indexName)) { CreateUniqueIndex(entityInfo.DbTableName, columnNames); diff --git a/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs b/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs index e5e06b83f..d95d68298 100644 --- a/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs +++ b/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs @@ -52,6 +52,8 @@ namespace SqlSugar /// public SugarDebugger Debugger { get; set; } + public string IndexSuffix { get; set; } + [JsonIgnore] public AopEvents AopEvents { get;set; } }