1414*/
1515
1616using System ;
17- using System . Collections . Generic ;
18- using System . Linq ;
19- using System . Text ;
20- using System . Threading . Tasks ;
21- using MongoDB . Bson ;
2217
2318namespace MongoDB . Driver
2419{
@@ -28,6 +23,7 @@ namespace MongoDB.Driver
2823 public class TransactionOptions
2924 {
3025 // private fields
26+ private readonly TimeSpan ? _maxCommitTime ;
3127 private readonly ReadConcern _readConcern ;
3228 private readonly ReadPreference _readPreference ;
3329 private readonly WriteConcern _writeConcern ;
@@ -39,17 +35,28 @@ public class TransactionOptions
3935 /// <param name="readConcern">The read concern.</param>
4036 /// <param name="readPreference">The read preference.</param>
4137 /// <param name="writeConcern">The write concern.</param>
38+ /// <param name="maxCommitTime">The max commit time.</param>
4239 public TransactionOptions (
4340 Optional < ReadConcern > readConcern = default ( Optional < ReadConcern > ) ,
4441 Optional < ReadPreference > readPreference = default ( Optional < ReadPreference > ) ,
45- Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) )
42+ Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) ,
43+ Optional < TimeSpan ? > maxCommitTime = default ( Optional < TimeSpan ? > ) )
4644 {
4745 _readConcern = readConcern . WithDefault ( null ) ;
4846 _readPreference = readPreference . WithDefault ( null ) ;
4947 _writeConcern = writeConcern . WithDefault ( null ) ;
48+ _maxCommitTime = maxCommitTime . WithDefault ( null ) ;
5049 }
5150
5251 // public properties
52+ /// <summary>
53+ /// Gets the max commit time.
54+ /// </summary>
55+ /// <value>
56+ /// The max commit time.
57+ /// </value>
58+ public TimeSpan ? MaxCommitTime => _maxCommitTime ;
59+
5360 /// <summary>
5461 /// Gets the read concern.
5562 /// </summary>
@@ -81,18 +88,21 @@ public TransactionOptions(
8188 /// <param name="readConcern">The new read concern.</param>
8289 /// <param name="readPreference">The read preference.</param>
8390 /// <param name="writeConcern">The new write concern.</param>
91+ /// <param name="maxCommitTime">The max commit time.</param>
8492 /// <returns>
8593 /// The new TransactionOptions.
8694 /// </returns>
8795 public TransactionOptions With (
8896 Optional < ReadConcern > readConcern = default ( Optional < ReadConcern > ) ,
8997 Optional < ReadPreference > readPreference = default ( Optional < ReadPreference > ) ,
90- Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) )
98+ Optional < WriteConcern > writeConcern = default ( Optional < WriteConcern > ) ,
99+ Optional < TimeSpan ? > maxCommitTime = default ( Optional < TimeSpan ? > ) )
91100 {
92101 return new TransactionOptions (
93102 readConcern : readConcern . WithDefault ( _readConcern ) ,
94103 readPreference : readPreference . WithDefault ( _readPreference ) ,
95- writeConcern : writeConcern . WithDefault ( _writeConcern ) ) ;
104+ writeConcern : writeConcern . WithDefault ( _writeConcern ) ,
105+ maxCommitTime : maxCommitTime . WithDefault ( _maxCommitTime ) ) ;
96106 }
97107 }
98108}
0 commit comments