mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 17:48:11 +08:00
UpdateColumns BUG
This commit is contained in:
@@ -119,6 +119,15 @@ namespace OrmTest.Demo
|
|||||||
var t25 = db.Updateable(new Student() { }).UpdateColumns(it=> new { it.Name,it.CreateTime}).WhereColumns(it => it.CreateTime).ExecuteCommand();
|
var t25 = db.Updateable(new Student() { }).UpdateColumns(it=> new { it.Name,it.CreateTime}).WhereColumns(it => it.CreateTime).ExecuteCommand();
|
||||||
|
|
||||||
var t26 = db.Updateable(new List<Student>() { new Student() { }, new Student() { } }).UpdateColumns(it => new { it.Name, it.CreateTime }).WhereColumns(it => it.CreateTime).ExecuteCommand();
|
var t26 = db.Updateable(new List<Student>() { new Student() { }, new Student() { } }).UpdateColumns(it => new { it.Name, it.CreateTime }).WhereColumns(it => it.CreateTime).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
db.Updateable<Student>().UpdateColumns(it => new Student { SchoolId = GeneratePassword(2, 1), Name =it.Name+1, CreateTime = DateTime.Now.AddDays(1) }).Where(it => it.Id == 1).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GeneratePassword(int v1, int v2)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -445,5 +445,38 @@ namespace SqlSugar
|
|||||||
Check.ThrowNotSupportedException(item.GetType().Name);
|
Check.ThrowNotSupportedException(item.GetType().Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected static Dictionary<string, string> MethodMapping = new Dictionary<string, string>() {
|
||||||
|
{ "ToString","ToString"},
|
||||||
|
{ "ToInt32","ToInt32"},
|
||||||
|
{ "ToInt16","ToInt32"},
|
||||||
|
{ "ToInt64","ToInt64"},
|
||||||
|
{ "ToDecimal","ToDecimal"},
|
||||||
|
{ "ToDateTime","ToDate"},
|
||||||
|
{ "ToBoolean","ToBool"},
|
||||||
|
{ "ToDouble","ToDouble"},
|
||||||
|
{ "Length","Length"},
|
||||||
|
{ "Replace","Replace"},
|
||||||
|
{ "Contains","Contains"},
|
||||||
|
{ "ContainsArray","ContainsArray"},
|
||||||
|
{ "EndsWith","EndsWith"},
|
||||||
|
{ "StartsWith","StartsWith"},
|
||||||
|
{ "HasValue","HasValue"},
|
||||||
|
{ "Trim","Trim"},
|
||||||
|
{ "Equals","Equals"},
|
||||||
|
{ "ToLower","ToLower"},
|
||||||
|
{ "ToUpper","ToUpper"},
|
||||||
|
{ "Substring","Substring"},
|
||||||
|
{ "DateAdd","DateAdd"}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected static Dictionary<string, DateType> MethodTimeMapping = new Dictionary<string, DateType>() {
|
||||||
|
{ "AddYears",DateType.Year},
|
||||||
|
{ "AddMonths",DateType.Month},
|
||||||
|
{ "AddDays",DateType.Day},
|
||||||
|
{ "AddHours",DateType.Hour},
|
||||||
|
{ "AddMinutes",DateType.Minute},
|
||||||
|
{ "AddSeconds",DateType.Second},
|
||||||
|
{ "AddMilliseconds",DateType.Millisecond}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,17 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (item is UnaryExpression)
|
if (item is UnaryExpression)
|
||||||
item = (item as UnaryExpression).Operand;
|
item = (item as UnaryExpression).Operand;
|
||||||
MethodCall(parameter, memberName, item);
|
var callMethod = item as MethodCallExpression;
|
||||||
|
if (MethodTimeMapping.Any(it => it.Key == callMethod.Method.Name) || MethodMapping.Any(it=>it.Key==callMethod.Method.Name)||IsExtMethod(callMethod.Method.Name)||IsSubMethod(callMethod)|| callMethod.Method.DeclaringType.FullName.StartsWith(UtilConstants.AssemblyName+UtilConstants.Dot))
|
||||||
|
{
|
||||||
|
MethodCall(parameter, memberName, item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var paramterValue = ExpressionTool.DynamicInvoke(item);
|
||||||
|
string parameterName = AppendParameter(paramterValue);
|
||||||
|
this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (IsConst(item))
|
else if (IsConst(item))
|
||||||
{
|
{
|
||||||
@@ -147,5 +157,19 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return SubTools.SubItemsConst.Any(it =>express.Object != null && express.Object.Type.Name == "Subqueryable`1");
|
return SubTools.SubItemsConst.Any(it =>express.Object != null && express.Object.Type.Name == "Subqueryable`1");
|
||||||
}
|
}
|
||||||
|
private bool IsExtMethod(string methodName)
|
||||||
|
{
|
||||||
|
if (this.Context.SqlFuncServices == null) return false;
|
||||||
|
return this.Context.SqlFuncServices.Select(it => it.UniqueMethodName).Contains(methodName);
|
||||||
|
}
|
||||||
|
private bool CheckMethod(MethodCallExpression expression)
|
||||||
|
{
|
||||||
|
if (IsExtMethod(expression.Method.Name))
|
||||||
|
return true;
|
||||||
|
if (expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -513,40 +513,6 @@ namespace SqlSugar
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, string> MethodMapping = new Dictionary<string, string>() {
|
|
||||||
{ "ToString","ToString"},
|
|
||||||
{ "ToInt32","ToInt32"},
|
|
||||||
{ "ToInt16","ToInt32"},
|
|
||||||
{ "ToInt64","ToInt64"},
|
|
||||||
{ "ToDecimal","ToDecimal"},
|
|
||||||
{ "ToDateTime","ToDate"},
|
|
||||||
{ "ToBoolean","ToBool"},
|
|
||||||
{ "ToDouble","ToDouble"},
|
|
||||||
{ "Length","Length"},
|
|
||||||
{ "Replace","Replace"},
|
|
||||||
{ "Contains","Contains"},
|
|
||||||
{ "ContainsArray","ContainsArray"},
|
|
||||||
{ "EndsWith","EndsWith"},
|
|
||||||
{ "StartsWith","StartsWith"},
|
|
||||||
{ "HasValue","HasValue"},
|
|
||||||
{ "Trim","Trim"},
|
|
||||||
{ "Equals","Equals"},
|
|
||||||
{ "ToLower","ToLower"},
|
|
||||||
{ "ToUpper","ToUpper"},
|
|
||||||
{ "Substring","Substring"},
|
|
||||||
{ "DateAdd","DateAdd"}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static Dictionary<string, DateType> MethodTimeMapping = new Dictionary<string, DateType>() {
|
|
||||||
{ "AddYears",DateType.Year},
|
|
||||||
{ "AddMonths",DateType.Month},
|
|
||||||
{ "AddDays",DateType.Day},
|
|
||||||
{ "AddHours",DateType.Hour},
|
|
||||||
{ "AddMinutes",DateType.Minute},
|
|
||||||
{ "AddSeconds",DateType.Second},
|
|
||||||
{ "AddMilliseconds",DateType.Millisecond}
|
|
||||||
};
|
|
||||||
|
|
||||||
private bool IsContainsArray(MethodCallExpression express, string methodName, bool isValidNativeMethod)
|
private bool IsContainsArray(MethodCallExpression express, string methodName, bool isValidNativeMethod)
|
||||||
{
|
{
|
||||||
return !isValidNativeMethod && express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains";
|
return !isValidNativeMethod && express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains";
|
||||||
|
Reference in New Issue
Block a user