@@ -16,8 +16,8 @@ namespace Xtensive.Orm.Tests.Issues
1616 public sealed class IssueJira0742_QueryPreprocessorClosureExpressionSupport
1717 {
1818 [ Test ]
19- [ TestCase ( true , TestName = "WithClosurePreprocessor" ) ]
20- [ TestCase ( false , TestName = "WithoutClosurePreprocessor" ) ]
19+ [ TestCase ( true ) ]
20+ [ TestCase ( false ) ]
2121 public void MainTest ( bool useClosurePreprocessor )
2222 {
2323 using ( var domain = BuildDomain ( useClosurePreprocessor ) )
@@ -27,13 +27,15 @@ public void MainTest(bool useClosurePreprocessor)
2727
2828 var simpleQuery = session . Query . All < TestEntity > ( ) . Count ( e => e . Id == TestMethod ( ) ) ;
2929 Assert . That ( simpleQuery , Is . EqualTo ( 1 ) ) ;
30+ session . Extensions . Clear ( ) ;
3031
3132 var simpleJoin = session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) )
3233 . Join ( session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) ) ,
3334 o => o . Id , i => i . Id , ( o , i ) => o )
3435 . Count ( ) ;
3536 Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
3637 Assert . That ( simpleJoin , Is . EqualTo ( 1 ) ) ;
38+ session . Extensions . Clear ( ) ;
3739
3840 var query = session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) ) ;
3941
@@ -43,10 +45,14 @@ public void MainTest(bool useClosurePreprocessor)
4345
4446 Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
4547 Assert . That ( variableJoin , Is . EqualTo ( 1 ) ) ;
48+ session . Extensions . Clear ( ) ;
4649
4750 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 ( ) ) ;
4954 Assert . That ( anyCount , Is . EqualTo ( 1 ) ) ;
55+ session . Extensions . Clear ( ) ;
5056
5157 var linqCount = ( from a in session . Query . All < TestEntity > ( ) . Where ( e => e . Id == TestMethod ( ) )
5258 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())
5561
5662 Assert . That ( session . Extensions . Get ( typeof ( ClosureMarker ) ) , GetSuccess ( ) ) ;
5763 Assert . That ( linqCount , Is . EqualTo ( 1 ) ) ;
64+ session . Extensions . Clear ( ) ;
5865
5966 var anyCountFail = session . Query . All < TestEntity > ( )
6067 . Count ( e => e . Id == TestMethod ( ) && query . Any ( z => z . Id == e . Id ) ) ;
@@ -142,7 +149,7 @@ public class TestVisitor : ExpressionVisitor
142149 protected override Expression VisitMember ( MemberExpression node )
143150 {
144151 if ( ! anyClosure ) {
145- anyClosure = node . Member . DeclaringType . IsClosure ( ) ;
152+ anyClosure = node . Type != typeof ( Session ) && node . Member . DeclaringType . IsClosure ( ) ;
146153 }
147154 return base . VisitMember ( node ) ;
148155 }
0 commit comments