Browse Source

Optimized code

pull/31/head
sunkaixuan 2 years ago
parent
commit
730cda1876
  1. 2
      Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs
  2. 2
      Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

2
Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

@ -423,7 +423,7 @@ namespace SqlSugar
item.Length = 36;
}
var columnInfo = oldColumns.FirstOrDefault(it => it.DbColumnName.EqualCase(item.DbColumnName));
if (columnInfo.ColumnDescription.ObjToString() != item.ColumnDescription.ObjToString())
if (columnInfo?.ColumnDescription.ObjToString() != item.ColumnDescription.ObjToString())
{
string sql = GetUpdateColumnSql(entity.DbTableName, mySqlCodeFirst.GetEntityColumnToDbColumn(entity, entity.DbTableName, item)) + " " + (item.IsIdentity ? "AUTO_INCREMENT" : "") + " " + " COMMENT '" + item.ColumnDescription + "'";
db.Ado.ExecuteCommand(sql);

2
Src/Asp.NetCore2/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

@ -424,7 +424,7 @@ namespace SqlSugar
item.Length = 36;
}
var columnInfo = oldColumns.FirstOrDefault(it => it.DbColumnName.EqualCase(item.DbColumnName));
if (columnInfo.ColumnDescription.ObjToString() != item.ColumnDescription.ObjToString())
if (columnInfo?.ColumnDescription.ObjToString() != item.ColumnDescription.ObjToString())
{
string sql = GetUpdateColumnSql(entity.DbTableName, mySqlCodeFirst.GetEntityColumnToDbColumn(entity, entity.DbTableName, item)) + " " + (item.IsIdentity ? "AUTO_INCREMENT" : "") + " " + " COMMENT '" + item.ColumnDescription + "'";
db.Ado.ExecuteCommand(sql);

Loading…
Cancel
Save