Synchronization Core

This commit is contained in:
sunkaixuan
2017-06-27 16:29:55 +08:00
parent 366006af96
commit ee999253c2
2 changed files with 12 additions and 3 deletions

View File

@@ -158,7 +158,7 @@ namespace SqlSugar
return reval;
}
public static object DynamicInvoke(MemberExpression expression)
public static object DynamicInvoke(Expression expression)
{
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
if (value != null && value.GetType().IsClass() && value.GetType() != ExpressionConst.StringType)

View File

@@ -14,8 +14,17 @@ namespace SqlSugar
var express = base.Expression as MethodCallExpression;
var isLeft = parameter.IsLeft;
string methodName = express.Method.Name;
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 (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");
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains")
{
methodName = "ContainsArray";
isValidNativeMethod = true;
}