@@ -90,11 +90,14 @@ public static RedisAggregationSet<T> Where<T>(this RedisAggregationSet<T> source
9090 public static IRedisCollection < T > Where < T > ( this IRedisCollection < T > source , Expression < Func < T , bool > > expression )
9191 where T : notnull
9292 {
93+ var collection = ( RedisCollection < T > ) source ;
94+ var combined = collection . BooleanExpression == null ? expression : collection . BooleanExpression . And ( expression ) ;
95+
9396 var exp = Expression . Call (
9497 null ,
9598 GetMethodInfo ( Where , source , expression ) ,
9699 new [ ] { source . Expression , Expression . Quote ( expression ) } ) ;
97- return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
100+ return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , combined , source . ChunkSize ) ;
98101 }
99102
100103 /// <summary>
@@ -113,7 +116,7 @@ public static IRedisCollection<TR> Select<T, TR>(this IRedisCollection<T> source
113116 null ,
114117 GetMethodInfo ( Select , source , expression ) ,
115118 new [ ] { source . Expression , Expression . Quote ( expression ) } ) ;
116- return new RedisCollection < TR > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
119+ return new RedisCollection < TR > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , null , source . ChunkSize ) ;
117120 }
118121
119122 /// <summary>
@@ -126,11 +129,12 @@ public static IRedisCollection<TR> Select<T, TR>(this IRedisCollection<T> source
126129 public static IRedisCollection < T > Skip < T > ( this IRedisCollection < T > source , int count )
127130 where T : notnull
128131 {
132+ var collection = ( RedisCollection < T > ) source ;
129133 var exp = Expression . Call (
130134 null ,
131135 GetMethodInfo ( Skip , source , count ) ,
132136 new [ ] { source . Expression , Expression . Constant ( count ) } ) ;
133- return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
137+ return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , collection . BooleanExpression , source . ChunkSize ) ;
134138 }
135139
136140 /// <summary>
@@ -143,11 +147,12 @@ public static IRedisCollection<T> Skip<T>(this IRedisCollection<T> source, int c
143147 public static IRedisCollection < T > Take < T > ( this IRedisCollection < T > source , int count )
144148 where T : notnull
145149 {
150+ var collection = ( RedisCollection < T > ) source ;
146151 var exp = Expression . Call (
147152 null ,
148153 GetMethodInfo ( Take , source , count ) ,
149154 new [ ] { source . Expression , Expression . Constant ( count ) } ) ;
150- return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
155+ return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , collection . BooleanExpression , source . ChunkSize ) ;
151156 }
152157
153158 /// <summary>
@@ -465,6 +470,7 @@ public static RedisAggregationSet<T> RandomSample<T, TResult>(this RedisAggregat
465470 public static IRedisCollection < T > GeoFilter < T > ( this IRedisCollection < T > source , Expression < Func < T , GeoLoc ? > > expression , double lon , double lat , double radius , GeoLocDistanceUnit unit )
466471 where T : notnull
467472 {
473+ var collection = ( RedisCollection < T > ) source ;
468474 var exp = Expression . Call (
469475 null ,
470476 GetMethodInfo ( GeoFilter , source , expression , lon , lat , radius , unit ) ,
@@ -474,7 +480,7 @@ public static IRedisCollection<T> GeoFilter<T>(this IRedisCollection<T> source,
474480 Expression . Constant ( lat ) ,
475481 Expression . Constant ( radius ) ,
476482 Expression . Constant ( unit ) ) ;
477- return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
483+ return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , collection . BooleanExpression , source . ChunkSize ) ;
478484 }
479485
480486 /// <summary>
@@ -488,11 +494,12 @@ public static IRedisCollection<T> GeoFilter<T>(this IRedisCollection<T> source,
488494 public static IRedisCollection < T > OrderBy < T , TField > ( this IRedisCollection < T > source , Expression < Func < T , TField > > expression )
489495 where T : notnull
490496 {
497+ var collection = ( RedisCollection < T > ) source ;
491498 var exp = Expression . Call (
492499 null ,
493500 GetMethodInfo ( OrderBy , source , expression ) ,
494501 new [ ] { source . Expression , Expression . Quote ( expression ) } ) ;
495- return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
502+ return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , collection . BooleanExpression , source . ChunkSize ) ;
496503 }
497504
498505 /// <summary>
@@ -506,11 +513,12 @@ public static IRedisCollection<T> OrderBy<T, TField>(this IRedisCollection<T> so
506513 public static IRedisCollection < T > OrderByDescending < T , TField > ( this IRedisCollection < T > source , Expression < Func < T , TField > > expression )
507514 where T : notnull
508515 {
516+ var collection = ( RedisCollection < T > ) source ;
509517 var exp = Expression . Call (
510518 null ,
511519 GetMethodInfo ( OrderByDescending , source , expression ) ,
512520 new [ ] { source . Expression , Expression . Quote ( expression ) } ) ;
513- return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , source . ChunkSize ) ;
521+ return new RedisCollection < T > ( ( RedisQueryProvider ) source . Provider , exp , source . StateManager , collection . BooleanExpression , source . ChunkSize ) ;
514522 }
515523
516524 /// <summary>
0 commit comments