mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update 人大金仓 UpdateColumn
This commit is contained in:
parent
0d420d867a
commit
4db1813811
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user