I'm trying to make a simple query to mongoDB using C# Driver. I've been trying a lot of things and then I came to this but it Always returns null.
Does anyone know if what could it be?
IMongoCollection<BsonDocument> users = Utilities.getCicCollection("Users");
var builder = Builders<BsonDocument>.Filter;
var filter= builder.Eq("Username", "test@test.it") & builder.Eq("Password", "testing");
var result = users.Find(filter).FirstOrDefault();
return (result!=null?true:false);
Use the standard snippet
var collection = _database.GetCollection<BsonDocument>("Users");
var builder = Builders<BsonDocument>.Filter;
var filter = builder.Eq("Username", "test@test.it") & builder.Eq("Password", "testing");
var list = await collection.Find(filter).ToListAsync()
var result = list.FirstOrDefault();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.