File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed
test/Redis.OM.Unit.Tests/RediSearchTests Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -648,8 +648,16 @@ private static string TranslateContainsStandardQuerySyntax(MethodCallExpression
648
648
literal = GetOperandStringForQueryArgs ( propertyExpression ) ;
649
649
if ( ! literal . StartsWith ( "@" ) )
650
650
{
651
- propertyExpression = ( MemberExpression ) exp . Arguments . First ( ) ;
652
- valuesExpression = ( MemberExpression ) exp . Arguments . Last ( ) ;
651
+ if ( exp . Arguments . Count == 1 && exp . Object != null )
652
+ {
653
+ propertyExpression = ( MemberExpression ) exp . Object ;
654
+ valuesExpression = ( MemberExpression ) exp . Arguments . Single ( ) ;
655
+ }
656
+ else
657
+ {
658
+ propertyExpression = ( MemberExpression ) exp . Arguments . First ( ) ;
659
+ valuesExpression = ( MemberExpression ) exp . Arguments . Last ( ) ;
660
+ }
653
661
}
654
662
else if ( propertyExpression == valuesExpression )
655
663
{
Original file line number Diff line number Diff line change @@ -2610,6 +2610,23 @@ public void SearchWithEmptyAny()
2610
2610
Assert . True ( any ) ;
2611
2611
}
2612
2612
2613
+ [ Fact ]
2614
+ public void TestContainsFromLocal ( )
2615
+ {
2616
+ _mock . Setup ( x => x . Execute ( It . IsAny < string > ( ) , It . IsAny < string [ ] > ( ) ) )
2617
+ . Returns ( _mockReply ) ;
2618
+ var collection = new RedisCollection < Person > ( _mock . Object ) ;
2619
+ var steve = "steve" ;
2620
+ collection . Where ( x => x . NickNamesList . Contains ( steve ) ) . ToList ( ) ;
2621
+ _mock . Verify ( x => x . Execute (
2622
+ "FT.SEARCH" ,
2623
+ "person-idx" ,
2624
+ "(@NickNamesList:{steve})" ,
2625
+ "LIMIT" ,
2626
+ "0" ,
2627
+ "100" ) ) ;
2628
+ }
2629
+
2613
2630
[ Fact ]
2614
2631
public void SearchGuidFieldContains ( )
2615
2632
{
@@ -2633,6 +2650,26 @@ public void SearchGuidFieldContains()
2633
2650
"100" ) ) ;
2634
2651
}
2635
2652
2653
+ [ Fact ]
2654
+ public void TestContainsFromProperty ( )
2655
+ {
2656
+ _mock . Setup ( x => x . Execute ( It . IsAny < string > ( ) , It . IsAny < string [ ] > ( ) ) )
2657
+ . Returns ( _mockReply ) ;
2658
+ var collection = new RedisCollection < Person > ( _mock . Object ) ;
2659
+ var steve = new Person
2660
+ {
2661
+ Name = "steve"
2662
+ } ;
2663
+ collection . Where ( x => x . NickNamesList . Contains ( steve . Name ) ) . ToList ( ) ;
2664
+ _mock . Verify ( x => x . Execute (
2665
+ "FT.SEARCH" ,
2666
+ "person-idx" ,
2667
+ "(@NickNamesList:{steve})" ,
2668
+ "LIMIT" ,
2669
+ "0" ,
2670
+ "100" ) ) ;
2671
+ }
2672
+
2636
2673
[ Fact ]
2637
2674
public void SearchUlidFieldContains ( )
2638
2675
{
You can’t perform that action at this time.
0 commit comments