[CSHARP-368] Query.In support for IEnumerable<ObjectId> Created: 19/Dec/11  Updated: 20/Mar/14  Resolved: 27/Apr/12

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.3.1
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Mariano Vicario Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

.Net



 Description   

The method Query.In supports IEnumerable<BsonValue> . So if I want to put a list<ObjectId> of ObjectIds I have to cast all the items to BSonValue.

It will be good an overload of Query.In supporting IENumerable<ObjectId>



 Comments   
Comment by Robert Stam [ 19/Dec/11 ]

I don't think we want to start adding overloads to Query.In.

Here's the shortest line of code I know of to pass an array of ObjectIs to Query.In:

Object[] ids;
var query = Query.In("_id", new BsonArray(ids));

You could also consider keeping your list of ObjectIds as a list or array of BsonValues to begin with and then you wouldn't even have to type "new BsonArray").

Generated at Wed Feb 07 21:36:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.