Exemplo n.º 1
0
        public static ICacheOptimizedQueryable <TResult> Select <TSource, TResult>(
            this ICacheOptimizedQueryable <TSource> source, Expression <Func <TSource, TResult> > selector)
        {
            var optimizationConfig  = source.OptimizationConfig;
            var optimizedExpression = OptimizeExpressionForCache(selector, optimizationConfig);

            return(source.AsQueryable().Select(optimizedExpression).AsCacheOptimizedQueryable());
        }
Exemplo n.º 2
0
        public static IQueryable <IGrouping <TKey, TSource> > GroupBy <TSource, TKey>(
            this ICacheOptimizedQueryable <TSource> source, Expression <Func <TSource, TKey> > keySelector)
        {
            var optimizationConfig   = source.OptimizationConfig;
            var keySelectorOptimised = OptimizeExpressionForCache(keySelector, optimizationConfig);

            return(source.AsQueryable().GroupBy(keySelectorOptimised).AsCacheOptimizedQueryable());
        }
Exemplo n.º 3
0
        private static TOut DecorateMethod <TSource, TExpression, TOut>(this ICacheOptimizedQueryable <TSource> source,
                                                                        TExpression expression, Func <IQueryable <TSource>, TExpression, TOut> method) where TExpression : Expression
        {
            var optimizationConfig  = source.OptimizationConfig;
            var optimizedExpression = OptimizeExpressionForCache(expression, optimizationConfig);
            var query = method(source.AsQueryable(), optimizedExpression);

            return(query);
        }
Exemplo n.º 4
0
        public static IQueryable <TResult> GroupBy <TSource, TKey, TResult>(this ICacheOptimizedQueryable <TSource> source,
                                                                            Expression <Func <TSource, TKey> > keySelector,
                                                                            Expression <Func <TKey, IEnumerable <TSource>, TResult> > resultSelector)
        {
            var optimizationConfig      = source.OptimizationConfig;
            var keySelectorOptimised    = OptimizeExpressionForCache(keySelector, optimizationConfig);
            var resultSelectorOptimised = OptimizeExpressionForCache(resultSelector, optimizationConfig);

            return(source.AsQueryable().GroupBy(keySelectorOptimised, resultSelectorOptimised)
                   .AsCacheOptimizedQueryable());
        }
Exemplo n.º 5
0
        public static ICacheOptimizedQueryable <TResult> SelectMany <TSource, TCollection, TResult>(
            this ICacheOptimizedQueryable <TSource> source,
            Expression <Func <TSource, IEnumerable <TCollection> > > collectionSelector,
            Expression <Func <TSource, TCollection, TResult> > resultSelector)
        {
            var optimizationConfig          = source.OptimizationConfig;
            var collectionSelectorOptimized = OptimizeExpressionForCache(collectionSelector, optimizationConfig);
            var resultSelectorOptimized     = OptimizeExpressionForCache(resultSelector, optimizationConfig);

            return(source.AsQueryable().SelectMany(collectionSelectorOptimized, resultSelectorOptimized)
                   .AsCacheOptimizedQueryable());
        }
Exemplo n.º 6
0
        //TODO: ADD WARNING FOR IQueryable And IEnumerable Outer
        public static IQueryable <TResult> Join <TOuter, TInner, TKey, TResult>(
            this ICacheOptimizedQueryable <TOuter> outer, ICacheOptimizedQueryable <TInner> inner,
            Expression <Func <TOuter, TKey> > outerKeySelector, Expression <Func <TInner, TKey> > innerKeySelector,
            Expression <Func <TOuter, TInner, TResult> > resultSelector)
        {
            var optimizationConfig      = outer.OptimizationConfig;
            var outerSelectorOptimized  = OptimizeExpressionForCache(outerKeySelector, optimizationConfig);
            var innerSelectorOptimized  = OptimizeExpressionForCache(innerKeySelector, optimizationConfig);
            var resultSelectorOptimized = OptimizeExpressionForCache(resultSelector, optimizationConfig);

            return(outer.AsQueryable().Join(inner.AsQueryable(), outerSelectorOptimized, innerSelectorOptimized,
                                            resultSelectorOptimized));
        }
Exemplo n.º 7
0
 public static TSource FirstOrDefault <TSource>(this ICacheOptimizedQueryable <TSource> source,
                                                Expression <Func <TSource, bool> > predicate)
 {
     return(DecorateMethod(source, predicate, (q, e) => q.FirstOrDefault(e)));
 }
Exemplo n.º 8
0
 public static bool Any <TSource>(this ICacheOptimizedQueryable <TSource> source,
                                  Expression <Func <TSource, bool> > predicate)
 {
     return(DecorateMethod(source, predicate, (q, e) => q.Any(e)));
 }
Exemplo n.º 9
0
 public static ICacheOptimizedQueryable <TSource> Where <TSource>(this ICacheOptimizedQueryable <TSource> source,
                                                                  Expression <Func <TSource, int, bool> > predicate)
 {
     return(DecorateMethod(source, predicate, (q, e) => q.Where(e)).AsCacheOptimizedQueryable());
 }
Exemplo n.º 10
0
 public static ICacheOptimizedQueryable <TResult> SelectMany <TSource, TResult>(
     this ICacheOptimizedQueryable <TSource> source, Expression <Func <TSource, IEnumerable <TResult> > > selector)
 {
     return(DecorateMethod(source, selector, (q, e) => q.SelectMany(e)).AsCacheOptimizedQueryable());
 }
Exemplo n.º 11
0
 public static IOrderedCacheOptimizedQueryable <TSource> OrderByDescending <TSource, TKey>(
     this ICacheOptimizedQueryable <TSource> source, Expression <Func <TSource, TKey> > keySelector)
 {
     return(DecorateMethod(source, keySelector, (q, e) => q.OrderByDescending(e))
            .AsOrderedCacheOptimizedQueryable());
 }