Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I need to have a query as such
Query.And(Query.NE("name", name[0]), Query.NE("name", name[1]));
However I don't know the number of elements in name[] and I need to make a AND of NE of all elements of name[].
Is there a way to build it?
Query
$nin
The Query.AND() method signature takes IEnumerable<IMongoQuery> parameter type so you could write your method as follows for any number of items:
Query.AND()
IEnumerable<IMongoQuery>
Query.AND(name.Select( x=> Query.NE("name", x));
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
Querycoming from?) I'd expect you'd find your answer by searching a little more. Here's a random cheat sheet layerworks.com/blog/2014/11/11/…$ninhere instead; that way you don't have to build your query dynamically and it will be more efficient.