Mongodb and csharp

De Banane Atomic
Aller à la navigationAller à la recherche

Access to a collection

Cs.svg
var mongoClient = new MongoClient("MONGODB_CONNECTION_STRING");
var database = mongoClient.GetDatabase("DB_NAME");
var collection = database.GetCollection<Collection>("COLLECTION_NAME");

Filter

Cs.svg
var builder = Builders<MyClass>.Filter;
var filter = builder.In(x => x.Property1, Ids); // filter by Property1 in the Ids list