Beispiel #1
0
        /// <summary>
        /// Given a Queryable and a QueryableEvaluator realizes the query asynchronously
        /// </summary>
        /// <param name="queryable">IQueryable</param>
        /// <param name="evaluator">IQueryableEvaluator</param>
        /// <param name="cancellationToken">CancelationToken</param>
        /// <returns>Data resulting from the query</returns>
        public override async Task <IPagedQueryResult <TResult> > RunAsync(IQueryable <TEntity> queryable, IQueryableEvaluator evaluator, CancellationToken cancellationToken = default)
        {
            queryable  = this.RunQuery(queryable);
            this.count = await evaluator.CountAsync(queryable, cancellationToken);

            queryable = this.Sort(queryable);
            queryable = this.Paginate(queryable);
            var result = await this.GenerateResultAsync(queryable, evaluator, cancellationToken);

            return(result);
        }
        /// <summary>
        /// Given a Queryable and a QueryableEvaluator realizes the query asynchronously
        /// </summary>
        /// <param name="queryable">IQueryable</param>
        /// <param name="evaluator">IQueryableEvaluator</param>
        /// <param name="cancellationToken">CancelationToken</param>
        /// <returns>Data resulting from the query</returns>
        public override async Task <IPagedQueryResult <TResult> > RunAsync(IQueryable <TEntity> queryable, IQueryableEvaluator evaluator, string[] includes, CancellationToken cancellationToken = default)
        {
            queryable  = this.RunQuery(queryable);
            this.count = await evaluator.CountAsync(queryable, cancellationToken);

            queryable = this.Sort(queryable);
            queryable = this.Paginate(queryable);
            if (includes != null)
            {
                foreach (string include in includes)
                {
                    queryable = queryable.Include(include);
                }
            }
            var result = await this.GenerateResultAsync(queryable, evaluator, cancellationToken);

            return(result);
        }