DeleteOneModel.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Copyright 2010-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 System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using MongoDB.Driver.Core.Misc;
  21. using MongoDB.Driver.Core.Operations;
  22. namespace MongoDB.Driver
  23. {
  24. /// <summary>
  25. /// Model for deleting a single document.
  26. /// </summary>
  27. /// <typeparam name="TDocument">The type of the document.</typeparam>
  28. #if NET452
  29. [Serializable]
  30. #endif
  31. public sealed class DeleteOneModel<TDocument> : WriteModel<TDocument>
  32. {
  33. // fields
  34. private Collation _collation;
  35. private readonly FilterDefinition<TDocument> _filter;
  36. // constructors
  37. /// <summary>
  38. /// Initializes a new instance of the <see cref="DeleteOneModel{TDocument}"/> class.
  39. /// </summary>
  40. /// <param name="filter">The filter.</param>
  41. public DeleteOneModel(FilterDefinition<TDocument> filter)
  42. {
  43. _filter = Ensure.IsNotNull(filter, nameof(filter));
  44. }
  45. // properties
  46. /// <summary>
  47. /// Gets or sets the collation.
  48. /// </summary>
  49. public Collation Collation
  50. {
  51. get { return _collation; }
  52. set { _collation = value; }
  53. }
  54. /// <summary>
  55. /// Gets the filter.
  56. /// </summary>
  57. public FilterDefinition<TDocument> Filter
  58. {
  59. get { return _filter; }
  60. }
  61. /// <summary>
  62. /// Gets the type of the model.
  63. /// </summary>
  64. public override WriteModelType ModelType
  65. {
  66. get { return WriteModelType.DeleteOne; }
  67. }
  68. }
  69. }