Ejemplo n.º 1
0
        private IQueryHandler <T> tryFindScalarQuery <T>(QueryModel model)
        {
            if (model.HasOperator <CountResultOperator>() || model.HasOperator <LongCountResultOperator>())
            {
                return(new CountQueryHandler <T>(model, _schema));
            }

            if (model.HasOperator <SumResultOperator>())
            {
                return(AggregateQueryHandler <T> .Sum(_schema, model));
            }

            if (model.HasOperator <AverageResultOperator>())
            {
                return(AggregateQueryHandler <T> .Average(_schema, model));
            }

            if (model.HasOperator <AnyResultOperator>())
            {
                return(new AnyQueryHandler(model, _schema).As <IQueryHandler <T> >());
            }

            return(null);
        }
Ejemplo n.º 2
0
        private IQueryHandler <T> tryFindScalarQuery <T>(QueryModel model, IIncludeJoin[] joins, QueryStatistics stats)
        {
            if (model.HasOperator <CountResultOperator>() || model.HasOperator <LongCountResultOperator>())
            {
                return(new LinqQuery <T>(_store, model, joins, stats).ToCount <T>());
            }

            if (model.HasOperator <SumResultOperator>())
            {
                return(AggregateQueryHandler <T> .Sum(new LinqQuery <T>(_store, model, joins, stats)));
            }

            if (model.HasOperator <AverageResultOperator>())
            {
                return(AggregateQueryHandler <T> .Average(new LinqQuery <T>(_store, model, joins, stats)));
            }

            if (model.HasOperator <AnyResultOperator>())
            {
                return(new LinqQuery <T>(_store, model, joins, stats).ToAny().As <IQueryHandler <T> >());
            }

            return(null);
        }