@@ -413,6 +413,51 @@ public void Can_Where_using_filter_with_nested_properties()
413
413
Assert . That ( target . Count , Is . EqualTo ( 1 ) ) ;
414
414
}
415
415
416
+ [ Test ]
417
+ public void Can_Where_using_filter_with_ToString ( )
418
+ {
419
+ string filterText = "10" ;
420
+ int filterInt = 10 ;
421
+
422
+ var q = Db . From < TestType > ( ) . Where ( x => x . NullableIntCol . ToString ( ) == filterText ) ;
423
+ var target = Db . Select ( q ) ;
424
+ Assert . That ( target . Count , Is . EqualTo ( 1 ) ) ;
425
+
426
+ q = Db . From < TestType > ( ) . Where ( x => x . NullableIntCol . ToString ( ) == null ) ;
427
+ target = Db . Select ( q ) ;
428
+ Assert . That ( target . Count , Is . EqualTo ( 1 ) ) ;
429
+
430
+ q = Db . From < TestType > ( ) . Where ( x => x . NullableIntCol . ToString ( ) == filterInt . ToString ( ) ) ;
431
+ target = Db . Select ( q ) ;
432
+ Assert . That ( target . Count , Is . EqualTo ( 1 ) ) ;
433
+
434
+ q = Db . From < TestType > ( ) . Where ( x => x . NullableIntCol . ToString ( ) == "NotNumeric" ) ;
435
+ target = Db . Select ( q ) ;
436
+ Assert . That ( target . Count , Is . EqualTo ( 0 ) ) ;
437
+
438
+ q = Db . From < TestType > ( ) .
439
+ Join < TestType2 > ( ) .
440
+ Where ( x => x . NullableIntCol . ToString ( ) == filterText && x . TestType2ObjCol . NullableIntCol . ToString ( ) == filterText ) ;
441
+ target = Db . Select ( q ) ;
442
+ Assert . That ( target . Count , Is . EqualTo ( 1 ) ) ;
443
+
444
+ q = Db . From < TestType > ( ) .
445
+ Join < TestType2 > ( ) .
446
+ Where ( x => x . NullableIntCol . ToString ( ) == filterText && x . TestType2ObjCol . NullableIntCol . ToString ( ) == "NotNumeric" ) ;
447
+ target = Db . Select ( q ) ;
448
+ Assert . That ( target . Count , Is . EqualTo ( 0 ) ) ;
449
+
450
+ var filterText2 = "qwer" ;
451
+
452
+ q = Db . From < TestType > ( ) . Where ( x => x . TextCol . ToString ( ) == filterText2 ) ;
453
+ target = Db . Select ( q ) ;
454
+ Assert . That ( target . Count , Is . EqualTo ( 1 ) ) ;
455
+
456
+ q = Db . From < TestType > ( ) . Where ( x => x . NullableIntCol . ToString ( ) . EndsWith ( "0" ) ) ;
457
+ target = Db . Select ( q ) ;
458
+ Assert . That ( target . Count , Is . EqualTo ( 3 ) ) ;
459
+ }
460
+
416
461
private int MethodReturningInt ( int val )
417
462
{
418
463
return val ;
0 commit comments