Compatible with .NET CORE

This commit is contained in:
sunkaixuan
2017-07-01 13:05:26 +08:00
parent 963c7de85d
commit 91a4e02a05
4 changed files with 16 additions and 11 deletions

View File

@@ -70,10 +70,14 @@ namespace SqlSugar
return type.GetTypeInfo().IsValueType; return type.GetTypeInfo().IsValueType;
} }
public static bool IsEntity(this Type type) public static bool IsEntity(this Type type)
{ {
return type.GetTypeInfo().IsClass(); return type.GetTypeInfo().IsClass();
} }
public static Type ReflectedType(this MethodInfo method)
{
return method.ReflectedType;
}
} }
} }

View File

@@ -265,7 +265,7 @@ namespace SqlSugar
private void CheckMethod(MethodCallExpression expression) private void CheckMethod(MethodCallExpression expression)
{ {
Check.Exception(expression.Method.ReflectedType.FullName != ExpressionConst.SqlFuncFullName,string.Format(ExpressionErrorMessage.MethodError, expression.Method.Name)); Check.Exception(expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName,string.Format(ExpressionErrorMessage.MethodError, expression.Method.Name));
} }
} }
} }

View File

@@ -14,17 +14,15 @@ 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") if (methodName == "get_Item") {
{ string paramterName =this.Context.SqlParameterKeyWord+ExpressionConst.Const + this.Context.ParameterIndex;
string paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express))); this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
this.Context.Result.Append(string.Format(" {0} ", paramterName)); this.Context.Result.Append(string.Format(" {0} ",paramterName));
this.Context.ParameterIndex++; this.Context.ParameterIndex++;
return; 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";
isValidNativeMethod = true; isValidNativeMethod = true;
} }
@@ -267,7 +265,7 @@ namespace SqlSugar
private void CheckMethod(MethodCallExpression expression) private void CheckMethod(MethodCallExpression expression)
{ {
Check.Exception(expression.Method.DeclaringType.FullName != ExpressionConst.SqlFuncFullName, string.Format(ExpressionErrorMessage.MethodError, expression.Method.Name)); Check.Exception(expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName,string.Format(ExpressionErrorMessage.MethodError, expression.Method.Name));
} }
} }
} }

View File

@@ -63,11 +63,14 @@ namespace SqlSugar
return type.GetTypeInfo().IsValueType; return type.GetTypeInfo().IsValueType;
} }
public static bool IsEntity(this Type type) public static bool IsEntity(this Type type)
{ {
return type.GetTypeInfo().IsClass; return type.GetTypeInfo().IsClass;
} }
public static Type ReflectedType(this MethodInfo method)
{
return method.DeclaringType;
}
} }
} }