File tree Expand file tree Collapse file tree 6 files changed +18
-23
lines changed Expand file tree Collapse file tree 6 files changed +18
-23
lines changed Original file line number Diff line number Diff line change @@ -100,8 +100,7 @@ public async Task WasCommittedOrRolledBackAsync()
100
100
Assert . IsFalse ( s . GetCurrentTransaction ( ) . WasRolledBack ) ;
101
101
await ( t . CommitAsync ( ) ) ;
102
102
103
- // ISession.GetCurrentTransaction() does not return a new transaction
104
- // if the previous one is completed.
103
+ // ISession.GetCurrentTransaction() returns null if the transaction is completed.
105
104
Assert . IsNull ( s . GetCurrentTransaction ( ) ) ;
106
105
107
106
Assert . IsTrue ( t . WasCommitted ) ;
@@ -113,8 +112,7 @@ public async Task WasCommittedOrRolledBackAsync()
113
112
{
114
113
await ( t . RollbackAsync ( ) ) ;
115
114
116
- // ISession.GetCurrentTransaction() does not return a new transaction
117
- // if the previous one is completed.
115
+ // ISession.GetCurrentTransaction() returns null if the transaction is completed.
118
116
Assert . IsNull ( s . GetCurrentTransaction ( ) ) ;
119
117
120
118
Assert . IsTrue ( t . WasRolledBack ) ;
Original file line number Diff line number Diff line change @@ -102,8 +102,7 @@ public void WasCommittedOrRolledBack()
102
102
Assert . IsFalse ( s . GetCurrentTransaction ( ) . WasRolledBack ) ;
103
103
t . Commit ( ) ;
104
104
105
- // ISession.GetCurrentTransaction() does not return a new transaction
106
- // if the previous one is completed.
105
+ // ISession.GetCurrentTransaction() returns null if the transaction is completed.
107
106
Assert . IsNull ( s . GetCurrentTransaction ( ) ) ;
108
107
109
108
Assert . IsTrue ( t . WasCommitted ) ;
@@ -115,8 +114,7 @@ public void WasCommittedOrRolledBack()
115
114
{
116
115
t . Rollback ( ) ;
117
116
118
- // ISession.GetCurrentTransaction() does not return a new transaction
119
- // if the previous one is completed.
117
+ // ISession.GetCurrentTransaction() returns null if the transaction is completed.
120
118
Assert . IsNull ( s . GetCurrentTransaction ( ) ) ;
121
119
122
120
Assert . IsTrue ( t . WasRolledBack ) ;
Original file line number Diff line number Diff line change @@ -418,7 +418,7 @@ public ITransaction Transaction
418
418
}
419
419
420
420
/// <summary>
421
- /// The current transaction if any, else <see langword="null" />.
421
+ /// The current transaction if any is ongoing , else <see langword="null" />.
422
422
/// </summary>
423
423
public ITransaction CurrentTransaction => _transaction ;
424
424
Original file line number Diff line number Diff line change 14
14
15
15
namespace NHibernate
16
16
{
17
- // 6.0 TODO: Convert to interface methods
17
+ // 6.0 TODO: Convert most of these extensions to interface methods
18
18
public static class SessionExtensions
19
19
{
20
20
/// <summary>
@@ -40,9 +40,9 @@ public static IQueryBatch CreateQueryBatch(this ISession session)
40
40
return ReflectHelper . CastOrThrow < AbstractSessionImpl > ( session , "query batch" ) . CreateQueryBatch ( ) ;
41
41
}
42
42
43
- // 6.0 TODO: add as property on ISession, obsolete this.
43
+ // 6.0 TODO: consider if it should be added as a property on ISession then obsolete this, or if it should stay here as an extension method .
44
44
/// <summary>
45
- /// Get the current transaction if any, else <see langword="null" />.
45
+ /// Get the current transaction if any is ongoing , else <see langword="null" />.
46
46
/// </summary>
47
47
/// <param name="session">The session.</param>
48
48
/// <returns>The current transaction or <see langword="null" />..</returns>
Original file line number Diff line number Diff line change 10
10
11
11
namespace NHibernate
12
12
{
13
- // 6.0 TODO: Convert to interface methods
13
+ // 6.0 TODO: Convert most of these extensions to interface methods
14
14
public static class StatelessSessionExtensions
15
15
{
16
16
/// <summary>
@@ -22,6 +22,15 @@ public static IQueryBatch CreateQueryBatch(this IStatelessSession session)
22
22
{
23
23
return ReflectHelper . CastOrThrow < AbstractSessionImpl > ( session , "query batch" ) . CreateQueryBatch ( ) ;
24
24
}
25
+
26
+ // 6.0 TODO: consider if it should be added as a property on IStatelessSession then obsolete this, or if it should stay here as an extension method.
27
+ /// <summary>
28
+ /// Get the current transaction if any is ongoing, else <see langword="null" />.
29
+ /// </summary>
30
+ /// <param name="session">The session.</param>
31
+ /// <returns>The current transaction or <see langword="null" />..</returns>
32
+ public static ITransaction GetCurrentTransaction ( this IStatelessSession session )
33
+ => session . GetSessionImplementation ( ) . ConnectionManager . CurrentTransaction ;
25
34
}
26
35
27
36
/// <summary>
@@ -57,11 +66,6 @@ public partial interface IStatelessSession : IDisposable
57
66
// Since v5.3
58
67
[ Obsolete ( "Use CurrentTransaction instead, and check for null." ) ]
59
68
ITransaction Transaction { get ; }
60
-
61
- /// <summary>
62
- /// The current transaction if any, else <see langword="null" />.
63
- /// </summary>
64
- ITransaction CurrentTransaction { get ; }
65
69
66
70
/// <summary>
67
71
/// Is the <c>IStatelessSession</c> still open?
Original file line number Diff line number Diff line change @@ -41,11 +41,6 @@ public abstract partial class AbstractSessionImpl : ISessionImplementor
41
41
[ Obsolete ( "Use CurrentTransaction instead, and check for null." ) ]
42
42
public ITransaction Transaction => ConnectionManager . Transaction ;
43
43
44
- /// <summary>
45
- /// The current transaction if any, else <see langword="null" />.
46
- /// </summary>
47
- public ITransaction CurrentTransaction => ConnectionManager . CurrentTransaction ;
48
-
49
44
protected bool IsTransactionCoordinatorShared { get ; }
50
45
51
46
public ITransactionContext TransactionContext
You can’t perform that action at this time.
0 commit comments