@@ -38,22 +38,19 @@ protected override void OnSetUp()
38
38
{
39
39
using ( var tran = session . BeginTransaction ( ) )
40
40
{
41
- Product product = new Product ( ) ;
42
- product . ProductId = "1" ;
41
+ var product = new Product { ProductId = "1" } ;
43
42
product . Details . Properties [ "Name" ] = "First Product" ;
44
43
product . Details . Properties [ "Description" ] = "First Description" ;
45
44
46
45
session . Save ( product ) ;
47
46
48
- product = new Product ( ) ;
49
- product . ProductId = "2" ;
47
+ product = new Product { ProductId = "2" } ;
50
48
product . Details . Properties [ "Name" ] = "Second Product" ;
51
49
product . Details . Properties [ "Description" ] = "Second Description" ;
52
50
53
51
session . Save ( product ) ;
54
52
55
- product = new Product ( ) ;
56
- product . ProductId = "3" ;
53
+ product = new Product { ProductId = "3" } ;
57
54
product . Details . Properties [ "Name" ] = "val" ;
58
55
product . Details . Properties [ "Description" ] = "val" ;
59
56
@@ -80,50 +77,52 @@ protected override void OnTearDown()
80
77
}
81
78
82
79
[ Test ]
83
- public void Query_DynamicComponent_In_Component ( )
80
+ public void CanQueryDynamicComponentInComponent ( )
84
81
{
85
82
using ( var session = OpenSession ( ) )
86
83
{
87
84
var query = session . CreateQuery ( "from Product p where p.Details.Properties.Name=:name" ) ;
88
85
query . SetString ( "name" , "First Product" ) ;
89
86
//var product = query.List<Product>().FirstOrDefault();
90
87
var product =
91
- ( from p in session . Query < Product > ( ) where p . Details . Properties [ "Name" ] == "First Product" select p ) . Single ( ) ;
88
+ ( from p in session . Query < Product > ( ) where ( string ) p . Details . Properties [ "Name" ] == "First Product" select p ) . Single ( ) ;
92
89
93
90
Assert . IsNotNull ( product ) ;
94
91
Assert . AreEqual ( "First Product" , product . Details . Properties [ "Name" ] ) ;
95
92
}
96
93
}
97
94
98
-
99
95
100
96
[ Test ]
101
- public void Multiple_Query_Does_Not_Cache ( )
97
+ public void MultipleQueriesShouldNotCache ( )
102
98
{
103
99
using ( var session = OpenSession ( ) )
104
100
{
105
101
// Query by name
106
102
var product1 = ( from p in session . Query < Product > ( )
107
- where p . Details . Properties [ "Name" ] == "First Product"
103
+ where ( string ) p . Details . Properties [ "Name" ] == "First Product"
108
104
select p ) . Single ( ) ;
109
105
Assert . That ( product1 . ProductId , Is . EqualTo ( "1" ) ) ;
110
106
111
107
// Query by description (this test is to verify that the dictionary
112
108
// index isn't cached from the query above.
113
109
var product2 = ( from p in session . Query < Product > ( )
114
- where p . Details . Properties [ "Description" ] == "Second Description"
110
+ where ( string ) p . Details . Properties [ "Description" ] == "Second Description"
115
111
select p ) . Single ( ) ;
116
112
Assert . That ( product2 . ProductId , Is . EqualTo ( "2" ) ) ;
117
113
}
118
114
}
119
115
116
+
120
117
[ Test ]
121
- public void Different_Key_In_DynamicComponentDictionary_Returns_Different_Keys ( )
118
+ public void DifferentKeyInDynamicComponentDictionaryReturnsDifferentExpressionKeys ( )
122
119
{
123
120
using ( var session = OpenSession ( ) )
124
121
{
125
- Expression < Func < IEnumerable > > key1 = ( ) => ( from a in session . Query < Product > ( ) where a . Details . Properties [ "Name" ] == "val" select a ) ;
126
- Expression < Func < IEnumerable > > key2 = ( ) => ( from a in session . Query < Product > ( ) where a . Details . Properties [ "Description" ] == "val" select a ) ;
122
+ // ReSharper disable AccessToDisposedClosure Ok since the expressions aren't actually used after the using block.
123
+ Expression < Func < IEnumerable > > key1 = ( ) => ( from a in session . Query < Product > ( ) where ( string ) a . Details . Properties [ "Name" ] == "val" select a ) ;
124
+ Expression < Func < IEnumerable > > key2 = ( ) => ( from a in session . Query < Product > ( ) where ( string ) a . Details . Properties [ "Description" ] == "val" select a ) ;
125
+ // ReSharper restore AccessToDisposedClosure
127
126
128
127
var nhKey1 = new NhLinqExpression ( key1 . Body , sessions ) ;
129
128
var nhKey2 = new NhLinqExpression ( key2 . Body , sessions ) ;
0 commit comments