Update DeleteableProvider

This commit is contained in:
sunkaixuan 2022-08-25 12:37:36 +08:00
parent 7e8c0576d3
commit 8537343a77
2 changed files with 15 additions and 1 deletions

View File

@ -107,6 +107,7 @@ namespace SqlSugar
var entityPropertyName = this.Context.EntityMaintenance.GetPropertyName<T>(primaryField);
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName.Equals(entityPropertyName, StringComparison.CurrentCultureIgnoreCase));
var value = columnInfo.PropertyInfo.GetValue(deleteObj, null);
value = UtilMethods.GetConvertValue(value);
primaryKeyValues.Add(value);
}
if (primaryKeyValues.Count < 10000)
@ -168,6 +169,11 @@ namespace SqlSugar
}
else
{
if ((columnInfo.SqlParameterDbType.ObjToString()==System.Data.DbType.AnsiString.ObjToString()) ||!(entityValue is string)||this.Context.CurrentConnectionConfig?.MoreSettings?.DisableNvarchar==true)
{
tempequals = tempequals.Replace("=N'", "='");
}
entityValue = UtilMethods.GetConvertValue(entityValue);
andString.AppendFormat(tempequals, primaryField, entityValue);
}
++i;
@ -179,7 +185,6 @@ namespace SqlSugar
}
return this;
}
public IDeleteable<T> Where(Expression<Func<T, bool>> expression)
{
var expResult = DeleteBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);

View File

@ -221,6 +221,15 @@ namespace SqlSugar
return info;
}
internal static object GetConvertValue(object entityValue)
{
if (entityValue != null && entityValue is DateTime)
{
entityValue = entityValue.ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff");
}
return entityValue;
}
internal static T To<T>(object value)
{
return (T)To(value, typeof(T));