同步代码

This commit is contained in:
sunkaixuan
2023-03-28 17:10:48 +08:00
parent 6bdfaa34be
commit ecf1718ab7
3 changed files with 18 additions and 5 deletions

View File

@@ -211,7 +211,7 @@ namespace SqlSugar
var date = dr.GetValue(i);
if (date is DateTime)
{
return UtilMethods.GetDateTimeOffsetByDateTime((DateTime)(date));
return new DateTimeOffset((DateTime)(date));
}
else
{
@@ -229,7 +229,7 @@ namespace SqlSugar
var date = dr.GetValue(i);
if (date is DateTime)
{
return UtilMethods.GetDateTimeOffsetByDateTime((DateTime)(date));
return new DateTimeOffset((DateTime)(date));
}
else
{

View File

@@ -410,6 +410,7 @@ namespace SqlSugar
}
public override bool AddRemark(EntityInfo entity)
{
var oldColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(entity.DbTableName, false);
var db = this.Context;
db.DbMaintenance.AddTableRemark(entity.DbTableName, entity.TableDescription);
List<EntityColumnInfo> columns = entity.Columns.Where(it => it.IsIgnore == false).ToList();
@@ -422,10 +423,14 @@ namespace SqlSugar
{
item.Length = 36;
}
var columnInfo = oldColumns.FirstOrDefault(it => it.DbColumnName.EqualCase(item.DbColumnName));
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);
}
}
}
return true;
}
protected override string GetCreateTableSql(string tableName, List<DbColumnInfo> columns)

View File

@@ -141,6 +141,10 @@ namespace SqlSugar
public static DateTime ObjToDate(this object thisValue)
{
if (thisValue is DateTime)
{
return (DateTime)thisValue;
}
DateTime reval = DateTime.MinValue;
if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
{
@@ -151,6 +155,10 @@ namespace SqlSugar
public static DateTime ObjToDate(this object thisValue, DateTime errorValue)
{
if (thisValue is DateTime)
{
return (DateTime)thisValue;
}
DateTime reval = DateTime.MinValue;
if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
{