File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
Visitors/ResultOperatorProcessors Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,23 @@ from o in c.Orders.WithLock(LockMode.Upgrade)
125
125
}
126
126
}
127
127
128
+ [ Test ]
129
+ public void CanSetLockOnBothJoinAndMainComplex ( )
130
+ {
131
+ using ( session . BeginTransaction ( ) )
132
+ {
133
+ var result = (
134
+ from c in db . Customers . Where ( x => true ) . WithLock ( LockMode . Upgrade )
135
+ from o in c . Orders . Where ( x => true ) . WithLock ( LockMode . Upgrade )
136
+ select new { o , c }
137
+ ) . ToList ( ) ;
138
+
139
+ Assert . That ( result , Has . Count . EqualTo ( 830 ) ) ;
140
+ Assert . That ( session . GetCurrentLockMode ( result [ 0 ] . o ) , Is . EqualTo ( LockMode . Upgrade ) ) ;
141
+ Assert . That ( session . GetCurrentLockMode ( result [ 0 ] . c ) , Is . EqualTo ( LockMode . Upgrade ) ) ;
142
+ }
143
+ }
144
+
128
145
[ Test ]
129
146
public void CanSetLockOnLinqPagingQuery ( )
130
147
{
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ namespace NHibernate.Linq
9
9
{
10
10
internal class LockResultOperator : ResultOperatorBase
11
11
{
12
- private readonly QuerySourceReferenceExpression _qsrExpression ;
12
+ private QuerySourceReferenceExpression _qsrExpression ;
13
13
14
- public string Alias => _qsrExpression . ReferencedQuerySource . ItemName ;
14
+ public IQuerySource QuerySource => _qsrExpression . ReferencedQuerySource ;
15
15
16
16
public ConstantExpression LockMode { get ; }
17
17
@@ -38,6 +38,7 @@ public override ResultOperatorBase Clone(CloneContext cloneContext)
38
38
39
39
public override void TransformExpressions ( Func < Expression , Expression > transformation )
40
40
{
41
+ _qsrExpression = ( QuerySourceReferenceExpression ) transformation ( _qsrExpression ) ;
41
42
}
42
43
}
43
44
}
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ internal class ProcessLock : IResultOperatorProcessor<LockResultOperator>
4
4
{
5
5
public void Process ( LockResultOperator resultOperator , QueryModelVisitor queryModelVisitor , IntermediateHqlTree tree )
6
6
{
7
- tree . AddAdditionalCriteria ( ( q , p ) => q . SetLockMode ( resultOperator . Alias , ( LockMode ) resultOperator . LockMode . Value ) ) ;
7
+ var alias = queryModelVisitor . VisitorParameters . QuerySourceNamer . GetName ( resultOperator . QuerySource ) ;
8
+ tree . AddAdditionalCriteria ( ( q , p ) => q . SetLockMode ( alias , ( LockMode ) resultOperator . LockMode . Value ) ) ;
8
9
}
9
10
}
10
11
}
You can’t perform that action at this time.
0 commit comments