Modify validation logic

This commit is contained in:
sunkaixuan
2019-05-25 08:09:09 +08:00
parent fb2eeaf171
commit 9a45e0cfe6

View File

@@ -620,21 +620,21 @@ namespace SqlSugar
Check.Exception(dbVersion == null, "UpdateVersionValidation database column {0} is not null", versionColumn.DbColumnName); Check.Exception(dbVersion == null, "UpdateVersionValidation database column {0} is not null", versionColumn.DbColumnName);
if (versionColumn.PropertyInfo.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.LongType)) if (versionColumn.PropertyInfo.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.LongType))
{ {
if (Convert.ToInt64(dbVersion) > Convert.ToInt64(currentVersion)) if (Convert.ToInt64(dbVersion) != Convert.ToInt64(currentVersion))
{ {
throw new VersionExceptions(string.Format("UpdateVersionValidation {0} Not the latest version ", versionColumn.PropertyName)); throw new VersionExceptions(string.Format("UpdateVersionValidation {0} Not the latest version ", versionColumn.PropertyName));
} }
} }
else if (versionColumn.PropertyInfo.PropertyType.IsIn(UtilConstants.DateType)) else if (versionColumn.PropertyInfo.PropertyType.IsIn(UtilConstants.DateType))
{ {
if (dbVersion.ObjToDate() > currentVersion.ObjToDate()) if (dbVersion.ObjToDate() != currentVersion.ObjToDate())
{ {
throw new VersionExceptions(string.Format("UpdateVersionValidation {0} Not the latest version ", versionColumn.PropertyName)); throw new VersionExceptions(string.Format("UpdateVersionValidation {0} Not the latest version ", versionColumn.PropertyName));
} }
} }
else if (versionColumn.PropertyInfo.PropertyType.IsIn(UtilConstants.ByteArrayType)) else if (versionColumn.PropertyInfo.PropertyType.IsIn(UtilConstants.ByteArrayType))
{ {
if (UtilMethods.GetLong((byte[])dbVersion) > UtilMethods.GetLong((byte[])currentVersion)) if (UtilMethods.GetLong((byte[])dbVersion) != UtilMethods.GetLong((byte[])currentVersion))
{ {
throw new VersionExceptions(string.Format("UpdateVersionValidation {0} Not the latest version ", versionColumn.PropertyName)); throw new VersionExceptions(string.Format("UpdateVersionValidation {0} Not the latest version ", versionColumn.PropertyName));
} }