AggregateOptions.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* Copyright 2015-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.Bson;
  17. using MongoDB.Driver.Core.Misc;
  18. namespace MongoDB.Driver
  19. {
  20. /// <summary>
  21. /// Options for an aggregate operation.
  22. /// </summary>
  23. public class AggregateOptions
  24. {
  25. // fields
  26. private bool? _allowDiskUse;
  27. private int? _batchSize;
  28. private bool? _bypassDocumentValidation;
  29. private Collation _collation;
  30. private string _comment;
  31. private BsonValue _hint;
  32. private TimeSpan? _maxAwaitTime;
  33. private TimeSpan? _maxTime;
  34. private ExpressionTranslationOptions _translationOptions;
  35. private bool? _useCursor;
  36. // properties
  37. /// <summary>
  38. /// Gets or sets a value indicating whether to allow disk use.
  39. /// </summary>
  40. public bool? AllowDiskUse
  41. {
  42. get { return _allowDiskUse; }
  43. set { _allowDiskUse = value; }
  44. }
  45. /// <summary>
  46. /// Gets or sets the size of a batch.
  47. /// </summary>
  48. public int? BatchSize
  49. {
  50. get { return _batchSize; }
  51. set { _batchSize = Ensure.IsNullOrGreaterThanOrEqualToZero(value, nameof(value)); }
  52. }
  53. /// <summary>
  54. /// Gets or sets a value indicating whether to bypass document validation.
  55. /// </summary>
  56. public bool? BypassDocumentValidation
  57. {
  58. get { return _bypassDocumentValidation; }
  59. set { _bypassDocumentValidation = value; }
  60. }
  61. /// <summary>
  62. /// Gets or sets the collation.
  63. /// </summary>
  64. public Collation Collation
  65. {
  66. get { return _collation; }
  67. set { _collation = value; }
  68. }
  69. /// <summary>
  70. /// Gets or sets the comment.
  71. /// </summary>
  72. public string Comment
  73. {
  74. get { return _comment; }
  75. set { _comment = value; }
  76. }
  77. /// <summary>
  78. /// Gets or sets the hint. This must either be a BsonString representing the index name or a BsonDocument representing the key pattern of the index.
  79. /// </summary>
  80. public BsonValue Hint
  81. {
  82. get { return _hint; }
  83. set { _hint = value; }
  84. }
  85. /// <summary>
  86. /// Gets or sets the maximum await time.
  87. /// </summary>
  88. public TimeSpan? MaxAwaitTime
  89. {
  90. get { return _maxAwaitTime; }
  91. set { _maxAwaitTime = value; }
  92. }
  93. /// <summary>
  94. /// Gets or sets the maximum time.
  95. /// </summary>
  96. public TimeSpan? MaxTime
  97. {
  98. get { return _maxTime; }
  99. set { _maxTime = Ensure.IsNullOrInfiniteOrGreaterThanOrEqualToZero(value, nameof(value)); }
  100. }
  101. /// <summary>
  102. /// Gets or sets the translation options.
  103. /// </summary>
  104. public ExpressionTranslationOptions TranslationOptions
  105. {
  106. get { return _translationOptions; }
  107. set { _translationOptions = value; }
  108. }
  109. /// <summary>
  110. /// Gets or sets a value indicating whether to use a cursor.
  111. /// </summary>
  112. public bool? UseCursor
  113. {
  114. get { return _useCursor; }
  115. set { _useCursor = value; }
  116. }
  117. }
  118. }