ClientSessionOptions.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright 2017-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 MongoDB.Driver.Core.Bindings;
  16. namespace MongoDB.Driver
  17. {
  18. /// <summary>
  19. /// Client session options.
  20. /// </summary>
  21. public class ClientSessionOptions
  22. {
  23. // public properties
  24. /// <summary>
  25. /// When true or unspecified, an application will read its own writes and subsequent
  26. /// reads will never observe an earlier version of the data.
  27. /// </summary>
  28. public bool? CausalConsistency { get; set; }
  29. /// <summary>
  30. /// Gets or sets the default transaction options.
  31. /// </summary>
  32. /// <value>
  33. /// The default transaction options.
  34. /// </value>
  35. public TransactionOptions DefaultTransactionOptions { get; set; }
  36. // internal methods
  37. internal CoreSessionOptions ToCore(bool isImplicit = false)
  38. {
  39. return new CoreSessionOptions(
  40. isCausallyConsistent: CausalConsistency ?? true,
  41. isImplicit: isImplicit,
  42. defaultTransactionOptions: DefaultTransactionOptions);
  43. }
  44. }
  45. }