Пример #1
0
        public OrQuery PredicateToQuery(Expression <Func <T, bool> > where)
        {
            // create a fake queryable to force query parsing and capture resolution

            var executor  = new NullExecutor(_typeDescription.AsTypeDescription);
            var queryable = new NullQueryable <T>(executor);

            var unused = queryable.Where(where).ToList();

            return(executor.Expression);
        }
Пример #2
0
        private OrQuery PredicateToQuery <T>(Expression <Func <T, bool> > predicate, string collectionName)
        {
            // convert the predicate to a serializable query
            // create a fake queryable to force query parsing and capture resolution

            var schema    = _connector.GetCollectionSchema(collectionName);
            var executor  = new NullExecutor(schema, collectionName);
            var queryable = new NullQueryable <T>(executor);

            var unused = queryable.Where(predicate).ToList();

            var query = executor.Expression;

            return(query);
        }
Пример #3
0
        /// <summary>
        ///     Precompile an expression tree as a query. It can be used to avoid parsing the expression tree multiple times
        /// </summary>
        /// <param name="where"></param>
        /// <param name="collectionName"></param>
        /// <returns></returns>
        public OrQuery PredicateToQuery(Expression <Func <T, bool> > where, string collectionName = null)
        {
            collectionName ??= _collectionSchema.CollectionName;

            // create a fake queryable to force query parsing and capture resolution
            var executor  = new NullExecutor(_collectionSchema, collectionName);
            var queryable = new NullQueryable <T>(executor);

            var unused = queryable.Where(where).ToList();

            var query = executor.Expression;

            query.CollectionName = _collectionName;

            return(query);
        }