Noel
Noel

Reputation: 5369

How to query for multiple results in mongoDB

If I want to find documents for more than one query parameter(sorry if not using correct wording), how do I do this? i am using the c# driver.

Example I want to find documents for both provider1 and provider2 I can do it for one i.e. collection.Find(Query.EQ("ProviderId", providerId))

In TSQL:

Select * From ProviderTable
Where ProviderId In (1,2)

Upvotes: 0

Views: 1329

Answers (1)

mookid8000
mookid8000

Reputation: 18628

If I understand you correctly, you're looking for this:

var ids = new List<int> {1, 2};

var results = collection.Find(Query.In("ProviderId", new BsonArray(ids)));

Upvotes: 2

Related Questions