InsertOneModel.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.Operations;
  21. namespace MongoDB.Driver
  22. {
  23. /// <summary>
  24. /// Model for inserting a single document.
  25. /// </summary>
  26. /// <typeparam name="TDocument">The type of the document.</typeparam>
  27. #if NET452
  28. [Serializable]
  29. #endif
  30. public sealed class InsertOneModel<TDocument> : WriteModel<TDocument>
  31. {
  32. // fields
  33. private readonly TDocument _document;
  34. // constructors
  35. /// <summary>
  36. /// Initializes a new instance of the <see cref="InsertOneModel{TDocument}"/> class.
  37. /// </summary>
  38. /// <param name="document">The document.</param>
  39. public InsertOneModel(TDocument document)
  40. {
  41. _document = document;
  42. }
  43. // properties
  44. /// <summary>
  45. /// Gets the document.
  46. /// </summary>
  47. public TDocument Document
  48. {
  49. get { return _document; }
  50. }
  51. /// <summary>
  52. /// Gets the type of the model.
  53. /// </summary>
  54. public override WriteModelType ModelType
  55. {
  56. get { return WriteModelType.InsertOne; }
  57. }
  58. }
  59. }