Reputation: 26658
I have entity.
class Something{
public List<string> Tags {get;set;}
}
Now I need query all entities that does not have given tag.
var res = s.Query<Something>()
.Where(x => !x.Tags.Any(t => t == "Test3"));
Fails with:
Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.MethodCallExpressionN' to type 'System.Linq.Expressions.MemberExpression'.
Plain query also does not work:
var res = s.Advanced.LuceneQuery<Something>()
.Where("-Tags:Test3");
... it simply returns nothing.
How to write such query?
Upvotes: 2
Views: 739
Reputation: 22956
There is an In extension method that you can use, which will also work with a !
Upvotes: 5
Reputation: 26658
Solution is simple:
var res = s.Advanced.LuceneQuery<Something>()
.Where("Tags:(* -Test3)");
Upvotes: 1