GridFSFindOptions.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright 2016-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using MongoDB.Driver.Core.Misc;
  17. namespace MongoDB.Driver.GridFS
  18. {
  19. /// <summary>
  20. /// Represents options for a GridFS Find operation.
  21. /// </summary>
  22. /// <typeparam name="TFileId">The type of the file identifier.</typeparam>
  23. public class GridFSFindOptions<TFileId>
  24. {
  25. // fields
  26. private int? _batchSize;
  27. private int? _limit;
  28. private TimeSpan? _maxTime;
  29. private bool? _noCursorTimeout;
  30. private int? _skip;
  31. private SortDefinition<GridFSFileInfo<TFileId>> _sort;
  32. // properties
  33. /// <summary>
  34. /// Gets or sets the batch size.
  35. /// </summary>
  36. /// <value>
  37. /// The batch size.
  38. /// </value>
  39. public int? BatchSize
  40. {
  41. get { return _batchSize; }
  42. set { _batchSize = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); }
  43. }
  44. /// <summary>
  45. /// Gets or sets the maximum number of documents to return.
  46. /// </summary>
  47. /// <value>
  48. /// The maximum number of documents to return.
  49. /// </value>
  50. public int? Limit
  51. {
  52. get { return _limit; }
  53. set { _limit = value; }
  54. }
  55. /// <summary>
  56. /// Gets or sets the maximum time the server should spend on the Find.
  57. /// </summary>
  58. /// <value>
  59. /// The maximum time the server should spend on the Find.
  60. /// </value>
  61. public TimeSpan? MaxTime
  62. {
  63. get { return _maxTime; }
  64. set { _maxTime = Ensure.IsNullOrInfiniteOrGreaterThanOrEqualToZero(value, nameof(value)); }
  65. }
  66. /// <summary>
  67. /// Gets or sets whether the cursor should not timeout.
  68. /// </summary>
  69. /// <value>
  70. /// Whether the cursor should not timeout.
  71. /// </value>
  72. public bool? NoCursorTimeout
  73. {
  74. get { return _noCursorTimeout; }
  75. set { _noCursorTimeout = value; }
  76. }
  77. /// <summary>
  78. /// Gets or sets the number of documents to skip.
  79. /// </summary>
  80. /// <value>
  81. /// The number of documents to skip.
  82. /// </value>
  83. public int? Skip
  84. {
  85. get { return _skip; }
  86. set { _skip = Ensure.IsNullOrGreaterThanOrEqualToZero(value, nameof(value)); }
  87. }
  88. /// <summary>
  89. /// Gets or sets the sort order.
  90. /// </summary>
  91. /// <value>
  92. /// The sort order.
  93. /// </value>
  94. public SortDefinition<GridFSFileInfo<TFileId>> Sort
  95. {
  96. get { return _sort; }
  97. set { _sort = value; }
  98. }
  99. }
  100. }