Update CodeFirst CreateIndex

This commit is contained in:
sunkaixuan 2022-06-25 14:36:36 +08:00
parent 2a20d4748e
commit 33a0662565
2 changed files with 9 additions and 1 deletions

View File

@ -21,6 +21,13 @@ namespace OrmTest
Db.Insertable(new UnitCodeFirst131() { Id = 1 }).ExecuteCommand();
Db.CodeFirst.InitTables<UNITCODEFIRST131>();
Db.CodeFirst.InitTables<UNITCOdEFIRST131>();
Db.CodeFirst.InitTables<UnitIndextest>();
}
[SqlSugar.SugarIndex("UnitIndextestIndex", nameof(UnitIndextest.Table),SqlSugar.OrderByType.Asc)]
public class UnitIndextest
{
public string Table { get; set; }
public string Id { get; set; }
}
public class UnitCodeFirst131
{

View File

@ -228,6 +228,7 @@ namespace SqlSugar
}
if (!this.Context.DbMaintenance.IsAnyIndex(item.IndexName))
{
var querybulder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
var fileds = item.IndexFields
.Select(it =>
{
@ -238,7 +239,7 @@ namespace SqlSugar
}
return new KeyValuePair<string, OrderByType>(dbColumn.DbColumnName, it.Value);
})
.Select(it => it.Key + " " + it.Value).ToArray();
.Select(it => querybulder.GetTranslationColumnName(it.Key) + " " + it.Value).ToArray();
this.Context.DbMaintenance.CreateIndex(entityInfo.DbTableName, fileds, item.IndexName, item.IsUnique);
}
}