mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-02 03:13:58 +08:00
Expression Dictionary BUG
This commit is contained in:
@@ -21,6 +21,7 @@ namespace OrmTest.UnitTest
|
|||||||
base.Begin();
|
base.Begin();
|
||||||
for (int i = 0; i < base.Count; i++)
|
for (int i = 0; i < base.Count; i++)
|
||||||
{
|
{
|
||||||
|
whereSingle16();
|
||||||
whereSingle15();
|
whereSingle15();
|
||||||
whereSingle1();
|
whereSingle1();
|
||||||
whereSingle2();
|
whereSingle2();
|
||||||
@@ -264,6 +265,21 @@ namespace OrmTest.UnitTest
|
|||||||
new SugarParameter("@Const0",1)
|
new SugarParameter("@Const0",1)
|
||||||
}, "whereSingle15");
|
}, "whereSingle15");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void whereSingle16()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||||
|
dic.Add("key", "x1");
|
||||||
|
Expression<Func<DataTestInfo, bool>> exp = it => it.String == dic["key"];
|
||||||
|
ExpressionContext expContext = new ExpressionContext();
|
||||||
|
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||||
|
var value = expContext.Result.GetString();
|
||||||
|
var pars = expContext.Parameters;
|
||||||
|
base.Check(value, pars, "( [String] = @Const0 )", new List<SugarParameter>()
|
||||||
|
{
|
||||||
|
new SugarParameter("@Const0",dic["key"])
|
||||||
|
}, "whereSingle16");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WhereConst
|
public class WhereConst
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ namespace SqlSugar
|
|||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static object DynamicInvoke(MemberExpression expression)
|
public static object DynamicInvoke(Expression expression)
|
||||||
{
|
{
|
||||||
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
|
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
|
||||||
if (value != null && value.GetType().IsClass && value.GetType() != ExpressionConst.StringType)
|
if (value != null && value.GetType().IsClass && value.GetType() != ExpressionConst.StringType)
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ namespace SqlSugar
|
|||||||
var express = base.Expression as MethodCallExpression;
|
var express = base.Expression as MethodCallExpression;
|
||||||
var isLeft = parameter.IsLeft;
|
var isLeft = parameter.IsLeft;
|
||||||
string methodName = express.Method.Name;
|
string methodName = express.Method.Name;
|
||||||
|
if (methodName == "get_Item") {
|
||||||
|
string paramterName =this.Context.SqlParameterKeyWord+ExpressionConst.Const + this.Context.ParameterIndex;
|
||||||
|
this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
|
||||||
|
this.Context.Result.Append(string.Format(" {0} ",paramterName));
|
||||||
|
this.Context.ParameterIndex++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var isValidNativeMethod = MethodMapping.ContainsKey(methodName)&&express.Method.DeclaringType.Namespace==("System");
|
var isValidNativeMethod = MethodMapping.ContainsKey(methodName)&&express.Method.DeclaringType.Namespace==("System");
|
||||||
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic")&&methodName=="Contains") {
|
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic")&&methodName=="Contains") {
|
||||||
methodName = "ContainsArray";
|
methodName = "ContainsArray";
|
||||||
|
|||||||
Reference in New Issue
Block a user