Synchronization code

This commit is contained in:
sunkaixuan 2023-09-13 14:12:31 +08:00
parent d435b21326
commit f13fba5f66
3 changed files with 13 additions and 1 deletions

View File

@ -408,6 +408,7 @@ namespace SqlSugar
dbColumns.Any(dc => dc.DbColumnName.EqualCase(ec.DbColumnName)
&& ((ec.Length != dc.Length && !UtilMethods.GetUnderType(ec.PropertyInfo).IsEnum() && UtilMethods.GetUnderType(ec.PropertyInfo).IsIn(UtilConstants.StringType)) ||
ec.IsNullable != dc.IsNullable ||
IsNoSamePrecision(ec, dc) ||
IsNoSamgeType(ec, dc)))).ToList();
var renameColumns = entityColumns
.Where(it => !string.IsNullOrEmpty(it.OldDbColumnName))
@ -500,6 +501,15 @@ namespace SqlSugar
}
}
private bool IsNoSamePrecision(EntityColumnInfo ec, DbColumnInfo dc)
{
if (this.Context.CurrentConnectionConfig.MoreSettings?.EnableCodeFirstUpdatePrecision == true)
{
return ec.DecimalDigits != dc.DecimalDigits && ec.UnderType.IsIn(UtilConstants.DobType,UtilConstants.DecType);
}
return false;
}
protected virtual void KeyAction(EntityColumnInfo item, DbColumnInfo dbColumn, out bool pkDiff, out bool idEntityDiff)
{
pkDiff = item.IsPrimarykey != dbColumn.IsPrimarykey;

View File

@ -25,5 +25,6 @@ namespace SqlSugar
public bool IsAutoDeleteQueryFilter { get; set; }
public bool EnableModelFuncMappingColumn { get; set; }
public bool EnableOracleIdentity { get; set; }
public bool EnableCodeFirstUpdatePrecision { get; set; }
}
}

View File

@ -471,7 +471,8 @@ namespace SqlSugar
IsAutoUpdateQueryFilter = it.MoreSettings.IsAutoUpdateQueryFilter,
EnableModelFuncMappingColumn=it.MoreSettings.EnableModelFuncMappingColumn,
EnableOracleIdentity = it.MoreSettings.EnableOracleIdentity,
IsWithNoLockSubquery=it.MoreSettings.IsWithNoLockSubquery
IsWithNoLockSubquery=it.MoreSettings.IsWithNoLockSubquery,
EnableCodeFirstUpdatePrecision=it.MoreSettings.EnableCodeFirstUpdatePrecision
},
SqlMiddle = it.SqlMiddle == null ? null : new SqlMiddle