find with $or in mongobd
db.inventory.find( { $or: [ { quantity: { $lt: 20 } }, { price: 10 } ] } )
find with $or in mongobd
db.inventory.find( { $or: [ { quantity: { $lt: 20 } }, { price: 10 } ] } )
Mongo Query
using System;
using MongoDB.Driver;
using MongoDB.Bson;
namespace MongoQuery
{
class Program
{
static void Main(string[] args)
{
var dbClient = new MongoClient("mongodb://127.0.0.1:27017");
IMongoDatabase db = dbClient.GetDatabase("testdb");
var cars = db.GetCollection<BsonDocument>("cars");
var builder = Builders<BsonDocument>.Filter;
var filter = builder.Gt("price", 30000) & builder.Lt("price", 55000);
var docs = cars.Find(filter).ToList();
docs.ForEach(doc => {
Console.WriteLine(doc);
});
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us