You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now it's impossible (workaround?) to use Any(Contains) construction.
Code example:
public void TestArrayContainsArray()
{
_substitute.ClearSubstitute();
_substitute.Execute(Arg.Any<string>(), Arg.Any<object[]>()).Returns(_mockReply);
var array = new[] { "Steve" };
var collection = new RedisCollection<Person>(_substitute, 1000);
_ = collection.Where(x => array.Any(x.NickNames.Contains)).ToList();
_substitute.Received().Execute(
"FT.SEARCH",
"person-idx",
"(@NickNames:{Steve})",
"LIMIT",
"0",
"1000"
);
}
Exception
System.InvalidCastException
Unable to cast object of type 'System.Linq.Expressions.UnaryExpression' to type 'System.Linq.Expressions.LambdaExpression'.
at Redis.OM.Common.ExpressionParserUtilities.TranslateAnyForEmbeddedObjects(MethodCallExpression exp, List`1 parameters) in C:\Projects\redis-om-dotnet\src\Redis.OM\Common\ExpressionParserUtilities.cs:line 962
at Redis.OM.Common.ExpressionParserUtilities.TranslateMethodExpressions(MethodCallExpression exp, List`1 parameters) in C:\Projects\redis-om-dotnet\src\Redis.OM\Common\ExpressionParserUtilities.cs:line 199
at Redis.OM.Common.ExpressionTranslator.BuildQueryFromExpression(Expression exp, List`1 parameters) in C:\Projects\redis-om-dotnet\src\Redis.OM\Common\ExpressionTranslator.cs:line 767
at Redis.OM.Common.ExpressionTranslator.TranslateWhereMethod(MethodCallExpression expression, List`1 parameters) in C:\Projects\redis-om-dotnet\src\Redis.OM\Common\ExpressionTranslator.cs:line 800
at Redis.OM.Common.ExpressionTranslator.BuildQueryFromExpression(Expression expression, Type type, Expression mainBooleanExpression, Type rootType) in C:\Projects\redis-om-dotnet\src\Redis.OM\Common\ExpressionTranslator.cs:line 232
at Redis.OM.Searching.RedisCollectionEnumerator`1..ctor(Expression exp, IRedisConnection connection, Int32 chunkSize, RedisCollectionStateManager stateManager, Expression`1 booleanExpression, Boolean saveState, Type rootType, Type type) in C:\Projects\redis-om-dotnet\src\Redis.OM\Searching\RedisCollectionEnumerator.cs:line 50
at Redis.OM.Searching.RedisCollection`1.GetEnumerator() in C:\Projects\redis-om-dotnet\src\Redis.OM\Searching\RedisCollection.cs:line 563
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Redis.OM.Unit.Tests.RediSearchTests.SearchTests.TestArrayContainsArray() in C:\Projects\redis-om-dotnet\test\Redis.OM.Unit.Tests\RediSearchTests\SearchTests.cs:line 918
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
The text was updated successfully, but these errors were encountered:
I think this is currently a limitation of the library, it is probably possible to build what you want but it would not be super performant - i.e. how many values would you allow NickNames to have?
The error message should probably be better, like a NotImplementedException, but I also agree the library should probably add support for this somehow.
Right now it's impossible (workaround?) to use Any(Contains) construction.
Code example:
Exception
The text was updated successfully, but these errors were encountered: