RobThree / MongoRepository

Repository abstraction layer on top of Official MongoDB C# driver
https://www.nuget.org/packages/MongoRepository/
MIT License
307 stars 141 forks source link

how to search mongodb for list of ids #40

Closed zhujinhu21 closed 8 years ago

zhujinhu21 commented 8 years ago

2 example documents of users:

{ "_id": ObjectId("abc"), "name": "Miroslav", "tenants": [ "jin" ] }

{ "_id": ObjectId("abd"), "name": "Lothar", "tenants": [ "zhu" ] } And I want to fire a single query to Mongo and get the matching documents . like sql server select * from users where id in('abc','abd') how MongoRepository to do. thank you.

RobThree commented 8 years ago

myrepo.Where(i => new [] { "abc", "abd" }.Contains(i.Id))

Written from the top of my head, details could slightly differ.