mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update CodeFirst CreateIndex
This commit is contained in:
parent
2a20d4748e
commit
33a0662565
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user