FindOneAndReplaceOptions.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* Copyright 2010-2016 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. namespace MongoDB.Driver
  17. {
  18. /// <summary>
  19. /// Options for a findAndModify command to replace an object.
  20. /// </summary>
  21. /// <typeparam name="TDocument">The type of the document.</typeparam>
  22. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  23. public class FindOneAndReplaceOptions<TDocument, TProjection>
  24. {
  25. // fields
  26. private bool? _bypassDocumentValidation;
  27. private Collation _collation;
  28. private bool _isUpsert;
  29. private TimeSpan? _maxTime;
  30. private ProjectionDefinition<TDocument, TProjection> _projection;
  31. private ReturnDocument _returnDocument;
  32. private SortDefinition<TDocument> _sort;
  33. // constructors
  34. /// <summary>
  35. /// Initializes a new instance of the <see cref="FindOneAndReplaceOptions{TDocument, TProjection}"/> class.
  36. /// </summary>
  37. public FindOneAndReplaceOptions()
  38. {
  39. _returnDocument = ReturnDocument.Before;
  40. }
  41. // properties
  42. /// <summary>
  43. /// Gets or sets the collation.
  44. /// </summary>
  45. public Collation Collation
  46. {
  47. get { return _collation; }
  48. set { _collation = value; }
  49. }
  50. /// <summary>
  51. /// Gets or sets a value indicating whether to bypass document validation.
  52. /// </summary>
  53. public bool? BypassDocumentValidation
  54. {
  55. get { return _bypassDocumentValidation; }
  56. set { _bypassDocumentValidation = value; }
  57. }
  58. /// <summary>
  59. /// Gets or sets a value indicating whether to insert the document if it doesn't already exist.
  60. /// </summary>
  61. public bool IsUpsert
  62. {
  63. get { return _isUpsert; }
  64. set { _isUpsert = value; }
  65. }
  66. /// <summary>
  67. /// Gets or sets the maximum time.
  68. /// </summary>
  69. public TimeSpan? MaxTime
  70. {
  71. get { return _maxTime; }
  72. set { _maxTime = value; }
  73. }
  74. /// <summary>
  75. /// Gets or sets the projection.
  76. /// </summary>
  77. public ProjectionDefinition<TDocument, TProjection> Projection
  78. {
  79. get { return _projection; }
  80. set { _projection = value; }
  81. }
  82. /// <summary>
  83. /// Gets or sets which version of the document to return.
  84. /// </summary>
  85. public ReturnDocument ReturnDocument
  86. {
  87. get { return _returnDocument; }
  88. set { _returnDocument = value; }
  89. }
  90. /// <summary>
  91. /// Gets or sets the sort.
  92. /// </summary>
  93. public SortDefinition<TDocument> Sort
  94. {
  95. get { return _sort; }
  96. set { _sort = value; }
  97. }
  98. }
  99. /// <summary>
  100. /// Options for a findAndModify command to replace an object.
  101. /// </summary>
  102. /// <typeparam name="TDocument">The type of the document and the result.</typeparam>
  103. public class FindOneAndReplaceOptions<TDocument> : FindOneAndReplaceOptions<TDocument, TDocument>
  104. {
  105. }
  106. }