mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
Update DbMaintenance
This commit is contained in:
@@ -87,12 +87,7 @@ namespace SqlSugar
|
||||
columns.Add(dbColumnInfo);
|
||||
}
|
||||
}
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns);
|
||||
var pkColumns = entityInfo.Columns.Where(it => it.IsPrimarykey).ToList();
|
||||
foreach (var item in pkColumns)
|
||||
{
|
||||
this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
|
||||
}
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns,true);
|
||||
}
|
||||
public virtual void ExistLogic(EntityInfo entityInfo)
|
||||
{
|
||||
|
@@ -141,13 +141,7 @@ namespace SqlSugar
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
}
|
||||
public virtual bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
||||
{
|
||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||
string sql = GetCreateTableSql(tableName, columns);
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
}
|
||||
public abstract bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true);
|
||||
public virtual bool DropTable(string tableName)
|
||||
{
|
||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||
|
@@ -20,7 +20,7 @@ namespace SqlSugar
|
||||
columns.Add(dbColumnInfo);
|
||||
}
|
||||
}
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns);
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns,true);
|
||||
}
|
||||
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
||||
{
|
||||
|
@@ -259,6 +259,11 @@ namespace SqlSugar
|
||||
return comments.HasValue() ? comments.First(it=>it.DbColumnName.Equals(filedName,StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : "";
|
||||
|
||||
}
|
||||
|
||||
public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -201,5 +201,20 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
||||
{
|
||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||
string sql = GetCreateTableSql(tableName, columns);
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
if (isCreatePrimaryKey) {
|
||||
var pkColumns = columns.Where(it => it.IsPrimarykey).ToList();
|
||||
foreach (var item in pkColumns)
|
||||
{
|
||||
this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ namespace SqlSugar
|
||||
columns.Add(dbColumnInfo);
|
||||
}
|
||||
}
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns);
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns,true);
|
||||
}
|
||||
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
||||
{
|
||||
|
Reference in New Issue
Block a user