@@ -16,8 +16,8 @@ namespace Xtensive.Orm.Tests.Issues
16
16
public sealed class IssueJira0742_QueryPreprocessorClosureExpressionSupport
17
17
{
18
18
[ Test ]
19
- [ TestCase ( true , TestName = "WithClosurePreprocessor" ) ]
20
- [ TestCase ( false , TestName = "WithoutClosurePreprocessor" ) ]
19
+ [ TestCase ( true ) ]
20
+ [ TestCase ( false ) ]
21
21
public void MainTest ( bool useClosurePreprocessor )
22
22
{
23
23
using ( var domain = BuildDomain ( useClosurePreprocessor ) )
@@ -27,13 +27,15 @@ public void MainTest(bool useClosurePreprocessor)
27
27
28
28
var simpleQuery = session . Query . All < TestEntity > ( ) . Count ( e => e . Id == TestMethod ( ) ) ;
29
29
Assert . That ( simpleQuery , Is . EqualTo ( 1 ) ) ;
30
+ session . Extensions . Clear ( ) ;
30
31
31
32
var simpleJoin = session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) )
32
33
. Join ( session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) ) ,
33
34
o => o . Id , i => i . Id , ( o , i ) => o )
34
35
. Count ( ) ;
35
36
Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
36
37
Assert . That ( simpleJoin , Is . EqualTo ( 1 ) ) ;
38
+ session . Extensions . Clear ( ) ;
37
39
38
40
var query = session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) ) ;
39
41
@@ -43,10 +45,14 @@ public void MainTest(bool useClosurePreprocessor)
43
45
44
46
Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
45
47
Assert . That ( variableJoin , Is . EqualTo ( 1 ) ) ;
48
+ session . Extensions . Clear ( ) ;
46
49
47
50
var anyCount = session . Query . All < TestEntity > ( )
48
- . Count ( e => e . Id == TestMethod ( ) && Query . All < TestEntity > ( ) . Where ( i => i . Id == TestMethod ( ) ) . Any ( z => z . Id == e . Id ) ) ;
51
+ . Count ( e => e . Id == TestMethod ( ) && session . Query . All < TestEntity > ( ) . Where ( i => i . Id == TestMethod ( ) ) . Any ( z => z . Id == e . Id ) ) ;
52
+
53
+ Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
49
54
Assert . That ( anyCount , Is . EqualTo ( 1 ) ) ;
55
+ session . Extensions . Clear ( ) ;
50
56
51
57
var linqCount = ( from a in session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) )
52
58
from b in session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) )
@@ -55,6 +61,7 @@ from b in session.Query.All<TestEntity>().Where(e => e.Id == TestMethod())
55
61
56
62
Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
57
63
Assert . That ( linqCount , Is . EqualTo ( 1 ) ) ;
64
+ session . Extensions . Clear ( ) ;
58
65
59
66
var anyCountFail = session . Query . All < TestEntity > ( )
60
67
. Count ( e => e . Id == TestMethod ( ) && query . Any ( z => z . Id == e . Id ) ) ;
@@ -142,7 +149,7 @@ public class TestVisitor : ExpressionVisitor
142
149
protected override Expression VisitMember ( MemberExpression node )
143
150
{
144
151
if ( ! anyClosure ) {
145
- anyClosure = node . Member . DeclaringType . IsClosure ( ) ;
152
+ anyClosure = node . Type != typeof ( Session ) && node . Member . DeclaringType . IsClosure ( ) ;
146
153
}
147
154
return base . VisitMember ( node ) ;
148
155
}
0 commit comments