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