@@ -33,9 +33,7 @@ public class NullComparisonTestsAsync : LinqTestCase
33
33
[ Test ]
34
34
public async Task NullInequalityWithNotNullAsync ( )
35
35
{
36
- IQueryable < AnotherEntityRequired > q ;
37
-
38
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Input != null ) ;
36
+ var q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Input != null ) ;
39
37
await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase , InputSet , BothSame , BothDifferent ) ) ;
40
38
41
39
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => null != o . Input ) ;
@@ -134,18 +132,6 @@ public async Task NullInequalityWithNotNullAsync()
134
132
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => ( o . Input + o . Output ) != o . Output ) ;
135
133
await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase , BothSame , BothDifferent ) ) ;
136
134
137
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Count != 1 ) ;
138
- await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
139
-
140
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Max ( r => r . Id ) != 0 ) ;
141
- await ( ExpectAllAsync ( q , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
142
-
143
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Take ( 10 ) . All ( r => r . Output != null ) != o . NullableBool ) ;
144
- await ( ExpectAllAsync ( q , Does . Not . Contain ( "or case" ) . IgnoreCase ) ) ;
145
-
146
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Where ( r => r . Id == 0 ) . Sum ( r => r . Input . Length ) != 5 ) ;
147
- await ( ExpectAllAsync ( q , Does . Contain ( "or (" ) . IgnoreCase ) ) ;
148
-
149
135
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Address . Street != o . Output ) ;
150
136
await ( ExpectAsync ( q , Does . Contain ( "Input is null" ) . IgnoreCase , BothDifferent , OutputSet , BothNull ) ) ;
151
137
@@ -157,6 +143,27 @@ public async Task NullInequalityWithNotNullAsync()
157
143
158
144
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Address . Street != null && o . Address . Street != o . NullableOutput ) ;
159
145
await ( ExpectAsync ( q , Does . Contain ( "Output is null" ) . IgnoreCase , InputSet , BothDifferent ) ) ;
146
+ }
147
+
148
+ [ Test ]
149
+ public async Task NullInequalityWithNotNullSubSelectAsync ( )
150
+ {
151
+ if ( ! Dialect . SupportsScalarSubSelects )
152
+ {
153
+ Assert . Ignore ( "Dialect does not support scalar subselects" ) ;
154
+ }
155
+
156
+ var q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Count != 1 ) ;
157
+ await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
158
+
159
+ q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Max ( r => r . Id ) != 0 ) ;
160
+ await ( ExpectAllAsync ( q , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
161
+
162
+ q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . All ( r => r . Output != null ) != o . NullableBool ) ;
163
+ await ( ExpectAllAsync ( q , Does . Not . Contain ( "or case" ) . IgnoreCase ) ) ;
164
+
165
+ q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Where ( r => r . Id == 0 ) . Sum ( r => r . Input . Length ) != 5 ) ;
166
+ await ( ExpectAllAsync ( q , Does . Contain ( "or (" ) . IgnoreCase ) ) ;
160
167
161
168
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . All ( r => r . Output != null ) != ( o . NullableOutput . Length > 0 ) ) ;
162
169
await ( ExpectAsync ( q , Does . Not . Contain ( "or case" ) . IgnoreCase ) ) ;
@@ -165,9 +172,7 @@ public async Task NullInequalityWithNotNullAsync()
165
172
[ Test ]
166
173
public async Task NullEqualityWithNotNullAsync ( )
167
174
{
168
- IQueryable < AnotherEntityRequired > q ;
169
-
170
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Input == null ) ;
175
+ var q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Input == null ) ;
171
176
await ( ExpectAsync ( q , Does . Not . Contain ( "or is null" ) . IgnoreCase , OutputSet , BothNull ) ) ;
172
177
173
178
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => null == o . Input ) ;
@@ -260,13 +265,7 @@ public async Task NullEqualityWithNotNullAsync()
260
265
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => ( o . NullableOutput + o . Output ) == o . Output ) ;
261
266
await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
262
267
263
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => ( o . Input + o . Output ) == o . Output ) ;
264
- await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
265
-
266
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Count == 1 ) ;
267
- await ( ExpectAllAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
268
-
269
- q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Max ( r => r . Id ) == 0 ) ;
268
+ q = session . Query < AnotherEntityRequired > ( ) . Where ( o => ( o . Output + o . Output ) == o . Output ) ;
270
269
await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
271
270
272
271
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => ! o . Input . Equals ( o . Output ) ) ;
@@ -294,6 +293,21 @@ public async Task NullEqualityWithNotNullAsync()
294
293
await ( ExpectAsync ( q , Does . Not . Contain ( "Output is null" ) . IgnoreCase , BothSame ) ) ;
295
294
}
296
295
296
+ [ Test ]
297
+ public async Task NullEqualityWithNotNullSubSelectAsync ( )
298
+ {
299
+ if ( ! Dialect . SupportsScalarSubSelects )
300
+ {
301
+ Assert . Ignore ( "Dialect does not support scalar subselects" ) ;
302
+ }
303
+
304
+ var q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Count == 1 ) ;
305
+ await ( ExpectAllAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
306
+
307
+ q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . RelatedItems . Max ( r => r . Id ) == 0 ) ;
308
+ await ( ExpectAsync ( q , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
309
+ }
310
+
297
311
298
312
[ Test ]
299
313
public async Task NullEqualityAsync ( )
0 commit comments