Update 人大金仓 UpdateColumn

This commit is contained in:
sunkaixuan 2022-10-12 09:29:14 +08:00
parent 0d420d867a
commit 4db1813811

View File

@ -240,6 +240,37 @@ namespace SqlSugar
#endregion
#region Methods
public override bool UpdateColumn(string tableName, DbColumnInfo columnInfo)
{
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
var columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
string type = GetType(tableName, columnInfo);
//this.Context.Ado.ExecuteCommand(sql);
string sql = @"ALTER TABLE {table} ALTER {column} TYPE {type};ALTER TABLE {table} ALTER COLUMN {column} {null}";
var isnull = columnInfo.IsNullable ? " DROP NOT NULL " : " SET NOT NULL ";
sql = sql.Replace("{table}", tableName)
.Replace("{type}", type)
.Replace("{column}", columnName)
.Replace("{null}", isnull);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
protected string GetType(string tableName, DbColumnInfo columnInfo)
{
string columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
string dataSize = GetSize(columnInfo);
string dataType = columnInfo.DataType;
//if (!string.IsNullOrEmpty(dataType))
//{
// dataType = dataType;
//}
return dataType + "" + dataSize;
}
public override bool IsAnyColumn(string tableName, string columnName, bool isCache = true)
{
var sql =