diff --git a/src/Redis.OM/Common/ExpressionTranslator.cs b/src/Redis.OM/Common/ExpressionTranslator.cs index 93fe4d6..f2f2be8 100644 --- a/src/Redis.OM/Common/ExpressionTranslator.cs +++ b/src/Redis.OM/Common/ExpressionTranslator.cs @@ -229,7 +229,7 @@ internal static RedisQuery BuildQueryFromExpression(Expression expression, Type query.GeoFilter = ExpressionParserUtilities.TranslateGeoFilter(exp); break; case "Where": - query.QueryText = TranslateWhereMethod(exp, parameters); + query.QueryText = query.QueryText == "*" ? TranslateWhereMethod(exp, parameters) : $"({TranslateWhereMethod(exp, parameters)} {query.QueryText})"; break; case "NearestNeighbors": query.NearestNeighbors = ParseNearestNeighborsFromExpression(exp); diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs index 92625fd..eada63d 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs @@ -3308,6 +3308,26 @@ public void TestSelectWithWhere() "Name"); } + [Fact] + public void TestSelectWithMultipleWheres() + { + _substitute.ClearSubstitute(); + _substitute.Execute(Arg.Any(), Arg.Any()).Returns(_mockReply); + IRedisCollection collection = new RedisCollection(_substitute); + collection = collection.Where(x => x.Name == "Steve"); + _ = collection.Where(x => x.Age == 33).Select(x => x.Name).ToList(); + _substitute.Received().Execute( + "FT.SEARCH", + "person-idx", + "((@Name:\"Steve\") (@Age:[33 33]))", + "LIMIT", + "0", + "100", + "RETURN", + "1", + "Name"); + } + [Fact] public void TestNullableEnumQueries()