From 09efff71d6d2b749477beb7a7bbb906fcda1509b Mon Sep 17 00:00:00 2001 From: apgk <1079248020@qq.com> Date: Wed, 18 Mar 2026 02:09:00 +0000 Subject: [PATCH] =?UTF-8?q?update=20Src/Asp.NetCore2/SqlSugar/Realization/?= =?UTF-8?q?MySql/DbMaintenance/MySqlDbMaintenance.cs.=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B1=8F=E8=94=BDmysql=E4=B8=8D=E6=94=AF=E6=8C=81include=20?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: apgk <1079248020@qq.com> --- .../MySql/DbMaintenance/MySqlDbMaintenance.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index 254c23d79..9d1f16aca 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Data; using System.Linq; @@ -751,6 +751,23 @@ WHERE EVENT_OBJECT_TABLE = '" + tableName + "'"); } return true; } + public override bool CreateIndex(string tableName, string[] columnNames, string IndexName, bool isUnique = false) + { + var include = ""; + if (IndexName.ToLower().Contains("{include:")) + { + include = Regex.Match(IndexName, @"\{include\:.+$").Value; + IndexName = IndexName.Replace(include, ""); + if (include == null) + { + throw new Exception("include format error"); + } + include = ""; + } + string sql = string.Format("CREATE {3} INDEX {2} ON {0}({1})" + include, this.SqlBuilder.GetTranslationColumnName(tableName), string.Join(",", columnNames), IndexName, isUnique ? "UNIQUE" : ""); + this.Context.Ado.ExecuteCommand(sql); + return true; + } #endregion -- Gitee