QueryResult.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. namespace MediaBrowser.Model.Querying;
  4. /// <summary>
  5. /// Query result container.
  6. /// </summary>
  7. /// <typeparam name="T">The type of item contained in the query result.</typeparam>
  8. public class QueryResult<T>
  9. {
  10. /// <summary>
  11. /// Initializes a new instance of the <see cref="QueryResult{T}" /> class.
  12. /// </summary>
  13. public QueryResult()
  14. {
  15. Items = Array.Empty<T>();
  16. }
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="QueryResult{T}" /> class.
  19. /// </summary>
  20. /// <param name="items">The list of items.</param>
  21. public QueryResult(IReadOnlyList<T> items)
  22. {
  23. Items = items;
  24. TotalRecordCount = items.Count;
  25. }
  26. /// <summary>
  27. /// Initializes a new instance of the <see cref="QueryResult{T}" /> class.
  28. /// </summary>
  29. /// <param name="startIndex">The start index that was used to build the item list.</param>
  30. /// <param name="totalRecordCount">The total count of items.</param>
  31. /// <param name="items">The list of items.</param>
  32. public QueryResult(int? startIndex, int? totalRecordCount, IReadOnlyList<T> items)
  33. {
  34. StartIndex = startIndex ?? 0;
  35. TotalRecordCount = totalRecordCount ?? items.Count;
  36. Items = items;
  37. }
  38. /// <summary>
  39. /// Gets or sets the items.
  40. /// </summary>
  41. /// <value>The items.</value>
  42. public IReadOnlyList<T> Items { get; set; }
  43. /// <summary>
  44. /// Gets or sets the total number of records available.
  45. /// </summary>
  46. /// <value>The total record count.</value>
  47. public int TotalRecordCount { get; set; }
  48. /// <summary>
  49. /// Gets or sets the index of the first record in Items.
  50. /// </summary>
  51. /// <value>First record index.</value>
  52. public int StartIndex { get; set; }
  53. }