public void Test_FdbQueryFilterExpression()
        {
            var expr = FdbQueryExpressions.Filter(
                FdbQueryExpressions.RangeStartsWith(TuPack.EncodeKey("Hello", "World")),
                (kvp) => kvp.Value.ToInt32() % 2 == 0
                );

            Log(expr);

            Assert.That(expr, Is.Not.Null);
            Assert.That(expr.Source, Is.Not.Null.And.InstanceOf <FdbQueryRangeExpression>());
            Assert.That(expr.Filter, Is.Not.Null);

            Assert.That(expr.Type, Is.EqualTo(typeof(IAsyncEnumerable <KeyValuePair <Slice, Slice> >)));
            Assert.That(expr.ElementType, Is.EqualTo(typeof(KeyValuePair <Slice, Slice>)));

            Log(FdbQueryExpressions.ExplainSequence(expr));
        }
Beispiel #2
0
        /// <summary>Filters a sequence query of values based on a predicate.</summary>
        public static IFdbAsyncSequenceQueryable <T> Where <T>(this IFdbAsyncSequenceQueryable <T> query, Expression <Func <T, bool> > predicate)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            var sourceExpr = query.Expression as FdbQuerySequenceExpression <T>;

            if (sourceExpr == null)
            {
                throw new ArgumentException("query");
            }

            var expr = FdbQueryExpressions.Filter(sourceExpr, predicate);

            return(query.Provider.CreateSequenceQuery <T>(expr));
        }