Ejemplo n.º 1
0
 public async Task <IEnumerable <Quote> > Handle(GetCollectionRequest <Quote> request, CancellationToken cancellationToken)
 {
     return(await _client.Quotes.GetDocumentQuery().ToAsyncEnumerable().ToArray());
 }
Ejemplo n.º 2
0
 public async Task <IEnumerable <StockTransaction> > Handle(GetCollectionRequest <StockTransaction> request, CancellationToken cancellationToken)
 {
     return(await _client.StockTransactions.GetDocumentQuery().ToAsyncEnumerable().ToArray());
 }
Ejemplo n.º 3
0
 public IEnumerable <Character> Handle(GetCollectionRequest <Character> message)
 {
     return(_client.Characters.GetDocumentQuery().ToArray());
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Applies the paging.
        /// </summary>
        /// <typeparam name="T">The type of the entity within the query.</typeparam>
        /// <param name="query">The query.</param>
        /// <param name="request">The request.</param>
        /// <returns>The paged and sorted query.</returns>
        private static IEnumerable <T> ApplyPagingAndSorting <T>(this IEnumerable <T> query, GetCollectionRequest request)
        {
            if (request != null)
            {
                Type t = typeof(T);
                if (t.IsPrimitive)
                {
                    query = query.OrderBy(x => x);
                }
                else if (request.Sort != null && request.Sort.Count() > 0)
                {
                    string orderClause = string.Join(", ", request.Sort);
                    query = query.OrderBy(orderClause);
                }

                if (request.Take == 0)
                {
                    request.Take = request.PageSize;
                }

                if (request.Take == 0)
                {
                    request.Take = 10;
                }

                if (request.Page > 0)
                {
                    request.Skip = (request.Page - 1) * request.PageSize;
                }

                query = query.Skip(request.Skip).Take(request.Take);
            }

            return(query);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Filters a query.
 /// </summary>
 /// <typeparam name="T">The type of the entity within the query.</typeparam>
 /// <param name="query">The query.</param>
 /// <param name="request">The request.</param>
 /// <param name="serializer">The serializer.</param>
 /// <returns>The filtered query.</returns>
 public static IEnumerable <T> Filter <T>(this IEnumerable <T> query, GetCollectionRequest request, ISerializationProvider serializer)
 {
     return(query.ApplyFilters(request, serializer));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Pages and sorts a query.
 /// </summary>
 /// <typeparam name="T">The type of the entity within the query.</typeparam>
 /// <param name="query">The query.</param>
 /// <param name="request">The request.</param>
 /// <returns>The paged and sorted query.</returns>
 public static IEnumerable <T> PageAndSort <T>(this IEnumerable <T> query, GetCollectionRequest request)
 {
     return(query.ApplyPagingAndSorting(request));
 }