Browse Source

Suport Collections.Generic

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
b623a08735
  1. 2
      SqlServerTest/UnitTest/ExpressionTest/Method.cs
  2. 2
      SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

2
SqlServerTest/UnitTest/ExpressionTest/Method.cs

@ -430,7 +430,7 @@ namespace OrmTest.UnitTest
} }
private void ExtendContainsArray() { private void ExtendContainsArray() {
string[] array = new string[] { "1", "2" }; var array = new string[] { "1", "2" }.ToList();
Expression<Func<Student, bool>> exp = it => array.Contains(it.Name); Expression<Func<Student, bool>> exp = it => array.Contains(it.Name);
SqlServerExpressionContext expContext = new SqlServerExpressionContext(); SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle); expContext.Resolve(exp, ResolveExpressType.WhereSingle);

2
SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

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

Loading…
Cancel
Save