diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index 254c23d797065fcdee075b18722c095c358ea500..9d1f16aca58519d420e9e5f9ff6a84f3bf128d31 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