private static ILinqQuery <TSource> Process <TSource>( ILinqQuery <TSource> query, Func <LinqQuery <TSource>, IQueryBuilderRecord> queryProcessor, Func <ILinqQueryInternal <TSource>, IEnumerable <TSource> > fallbackProcessor) { if (query == null) { throw new ArgumentNullException("query"); } var candidate = query as LinqQuery <TSource>; if (candidate == null) { return (new UnoptimizedQuery <TSource>(fallbackProcessor((ILinqQueryInternal <TSource>)EnsureLinqQuery(query)))); } try { var record = queryProcessor(candidate); return(new LinqQuery <TSource>(candidate, record)); } catch (LinqQueryException) { return(new UnoptimizedQuery <TSource>(fallbackProcessor(candidate))); } }
public static ILinqQuery <TSource> Where <TSource>(this ILinqQuery <TSource> self, Expression <Func <TSource, bool> > expression) { return(Process(self, query => new WhereClauseVisitor().Process(expression), data => data.UnoptimizedWhere(expression.Compile()) )); }
private static ILinqQuery <TSource> ProcessOrderBy <TSource, TKey>( ILinqQuery <TSource> query, ExpressionQueryBuilder visitor, Expression <Func <TSource, TKey> > expression, Func <ILinqQueryInternal <TSource>, IEnumerable <TSource> > fallbackProcessor) { return(Process(query, q => visitor.Process(expression), fallbackProcessor)); }
private static ILinqQuery <TSource> EnsureLinqQuery <TSource>(ILinqQuery <TSource> query) { var placeHolderQuery = query as PlaceHolderQuery <TSource>; return(placeHolderQuery == null ? query : new LinqQuery <TSource>(placeHolderQuery.QueryFactory)); }
private IQueryable <TResultEntity> AsQueryable <TResultEntity, TEntity>( ILinqQuery <TResultEntity, TEntity> query) where TResultEntity : class where TEntity : class { query.DataSource = _context.Set <TEntity>(); return(query.LinqQuery); }
public static ILinqQuery <TRet> Select <TSource, TRet>(this ILinqQuery <TSource> self, Func <TSource, TRet> selector) { var placeHolderQuery = self as PlaceHolderQuery <TSource>; if (placeHolderQuery != null) { return(new LinqQuery <TRet>(placeHolderQuery.QueryFactory)); } return(new UnoptimizedQuery <TRet>(Enumerable.Select(self, selector))); }
public static int Count <TSource>(this ILinqQuery <TSource> self) { if (self == null) { throw new ArgumentNullException("self"); } var query = self as LinqQuery <TSource>; return(query != null ? query.Count : Enumerable.Count(self)); }
public AggregateQueryHandler(string @operator, ILinqQuery query) { _operator = @operator; _query = query; if (typeof(T).Closes(typeof(Nullable <>))) { var typeInfo = typeof(T).GetTypeInfo(); var arguments = typeInfo.IsGenericTypeDefinition ? typeInfo.GenericTypeParameters : typeInfo.GenericTypeArguments; var inner = arguments.First(); _selector = typeof(NullableScalarSelector <>).CloseAndBuildAs <ISelector <T> >(inner); } else { _selector = new ScalarSelector <T>(); } }
public static AggregateQueryHandler <T> Max(ILinqQuery query) { return(new AggregateQueryHandler <T>("max({0})", query)); }
public LinqQueryable(ILinqQuery <TElement> query) { _expression = Expression.Constant(this); _query = query; }
public AnyQueryHandler(ILinqQuery query) { _query = query; }
public IQueryable <TEntity> AsQueryable <TEntity>(ILinqQuery <TEntity> query) where TEntity : class { return(AsQueryable(query as ILinqQuery <TEntity, TEntity>)); }
public static ILinqQuery <TSource> ThenBy <TSource, TKey>(this ILinqQuery <TSource> self, Expression <Func <TSource, TKey> > expression) { return(ProcessOrderBy(self, new OrderByAscendingClauseVisitor(), expression, data => data.UnoptimizedThenBy(expression.Compile()))); }
public static ILinqQueryable <TSource> AsQueryable <TSource>(this ILinqQuery <TSource> self) { return(new LinqQueryable <TSource>(self)); }
public static AggregateQueryHandler <T> Sum(ILinqQuery query) { return(new AggregateQueryHandler <T>("coalesce(sum({0}),0)", query)); }
public static AggregateQueryHandler <T> Average(ILinqQuery query) { return(new AggregateQueryHandler <T>("avg({0})", query)); }
public CountQueryHandler(ILinqQuery query) { _query = query; }