@@ -265,7 +265,13 @@ public async Task CanQueryByRandomIntAsync()
265
265
using ( var spy = new SqlLogSpy ( ) )
266
266
{
267
267
var random = new Random ( ) ;
268
- var x = await ( db . Orders . CountAsync ( o => o . OrderId - idMin - 1 < random . Next ( ) ) ) ;
268
+ // Dodge a Firebird driver limitation by putting the constants before the order id.
269
+ // This driver cast parameters to their types in some cases for avoiding Firebird complaining of not
270
+ // knowing the type of the condition. For some reasons the driver considers the casting should not be
271
+ // done next to the conditional operator. Having the cast only on one side is enough for avoiding
272
+ // Firebird complain, so moving the constants on the left side have been put before the order id, in
273
+ // order for these constants to be casted by the driver.
274
+ var x = await ( db . Orders . CountAsync ( o => - idMin - 1 + o . OrderId < random . Next ( ) ) ) ;
269
275
270
276
Assert . That ( x , Is . GreaterThan ( 0 ) ) ;
271
277
// Next requires support of both floor and rand
@@ -309,7 +315,13 @@ public async Task CanQueryByRandomIntWithMaxAsync()
309
315
using ( var spy = new SqlLogSpy ( ) )
310
316
{
311
317
var random = new Random ( ) ;
312
- var x = await ( db . Orders . CountAsync ( o => o . OrderId - idMin < random . Next ( 10 ) ) ) ;
318
+ // Dodge a Firebird driver limitation by putting the constants before the order id.
319
+ // This driver cast parameters to their types in some cases for avoiding Firebird complaining of not
320
+ // knowing the type of the condition. For some reasons the driver considers the casting should not be
321
+ // done next to the conditional operator. Having the cast only on one side is enough for avoiding
322
+ // Firebird complain, so moving the constants on the left side have been put before the order id, in
323
+ // order for these constants to be casted by the driver.
324
+ var x = await ( db . Orders . CountAsync ( o => - idMin + o . OrderId < random . Next ( 10 ) ) ) ;
313
325
314
326
Assert . That ( x , Is . GreaterThan ( 0 ) . And . LessThan ( 10 ) ) ;
315
327
// Next requires support of both floor and rand
@@ -353,7 +365,13 @@ public async Task CanQueryByRandomIntWithMinMaxAsync()
353
365
using ( var spy = new SqlLogSpy ( ) )
354
366
{
355
367
var random = new Random ( ) ;
356
- var x = await ( db . Orders . CountAsync ( o => o . OrderId - idMin < random . Next ( 1 , 11 ) ) ) ;
368
+ // Dodge a Firebird driver limitation by putting the constants before the order id.
369
+ // This driver cast parameters to their types in some cases for avoiding Firebird complaining of not
370
+ // knowing the type of the condition. For some reasons the driver considers the casting should not be
371
+ // done next to the conditional operator. Having the cast only on one side is enough for avoiding
372
+ // Firebird complain, so moving the constants on the left side have been put before the order id, in
373
+ // order for these constants to be casted by the driver.
374
+ var x = await ( db . Orders . CountAsync ( o => - idMin + o . OrderId < random . Next ( 1 , 11 ) ) ) ;
357
375
358
376
Assert . That ( x , Is . GreaterThan ( 0 ) . And . LessThan ( 10 ) ) ;
359
377
// Next requires support of both floor and rand
0 commit comments