public async Task <IEnumerable <Quote> > Handle(GetCollectionRequest <Quote> request, CancellationToken cancellationToken) { return(await _client.Quotes.GetDocumentQuery().ToAsyncEnumerable().ToArray()); }
public async Task <IEnumerable <StockTransaction> > Handle(GetCollectionRequest <StockTransaction> request, CancellationToken cancellationToken) { return(await _client.StockTransactions.GetDocumentQuery().ToAsyncEnumerable().ToArray()); }
public IEnumerable <Character> Handle(GetCollectionRequest <Character> message) { return(_client.Characters.GetDocumentQuery().ToArray()); }
/// <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); }
/// <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)); }
/// <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)); }