Browse Source

PredicateBuilder In with NULL handle

HOME 2 years ago
parent
commit
99a4b5a21b
1 changed files with 4 additions and 0 deletions
  1. 4 0
      VCommon/Linq.Expressions.Predicate/PredicateBuilder.cs

+ 4 - 0
VCommon/Linq.Expressions.Predicate/PredicateBuilder.cs

@@ -17,6 +17,8 @@ namespace VCommon.Linq.Expressions.Predicate
 
         public PredicateWrap<T> In<TV>(Expression<Func<T, TV>> selector, IEnumerable<TV> checkIn)
         {
+            if (checkIn == null) return null;
+
             var c = Constant(checkIn.WrapEnumerable());
             var p = selector.Parameters[0];
             var call = Call(typeof(Enumerable), "Contains", new[] { typeof(TV) }, c, selector.Body);
@@ -26,6 +28,8 @@ namespace VCommon.Linq.Expressions.Predicate
 
         public PredicateWrap<T> NotIn<TV>(Expression<Func<T, TV>> selector, IEnumerable<TV> checkIn)
         {
+            if (checkIn == null) return null;
+            
             var p = selector.Parameters[0];
             var values = Constant(checkIn.WrapEnumerable());
             var @in = Call(typeof(Enumerable), "Contains", new[] { typeof(TV) }, values, selector.Body);