示例#1
0
 /// <summary>
 /// Asynchronous method that materializes an <see cref="IQueryable{T}"/> <paramref name="source"/> using the <seealso cref="ListOptions"/>
 /// for paging and sorting.
 /// </summary>
 /// <typeparam name="T">The type to contain in the result items.</typeparam>
 /// <param name="source">The source collection</param>
 /// <param name="options">The options to use for sortig and paging</param>
 /// <returns>The results in a set that contains a page set of the total available records and the total count</returns>
 public static async Task <ResultSet <T> > ToResultSetAsync <T>(this IQueryable <T> source, ListOptions options)
 {
     options ??= new ListOptions();
     foreach (var sorting in options.GetSortings())
     {
         source = source.OrderBy(sorting.Path, sorting.Direction);
     }
     return(await source.ToResultSetAsync(options.Page, options.Size));
 }