示例#1
0
        static void FilterUsinEQWithFilterDifinitionBuilder()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = new FilterDefinitionBuilder <BsonDocument>().Eq("undergrad", false);

            collection.Find(filter).ForEachAsync(doc => Console.WriteLine(doc));
        }
示例#2
0
        static void FilterUsinEQWithBsonDocument()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = new BsonDocument("undergrad", new BsonDocument("$eq", false));

            collection.Find(filter).ForEachAsync(doc => Console.WriteLine(doc));
        }
示例#3
0
        static void FilterUsinEQWithString()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = "{undergrad: {'$eq': false}}";

            collection.Find(filter).ForEachAsync(doc => Console.WriteLine(doc));
        }
示例#4
0
        static void FilterWithString()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = "{Name: 'Keanu Reeves'}";

            collection.Find(filter).ForEachAsync(doc => Console.WriteLine(doc));
        }
示例#5
0
        static void FilterWithBsonDocument()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = new BsonDocument("Name", "Keanu Reeves");

            collection.Find(filter).ForEachAsync(doc => Console.WriteLine(doc));
        }
示例#6
0
        static void FilterByIdWithString()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = "{_id: ObjectId('5ea37c1edc6da61880bff131')}";

            var doc = collection.Find(filter).FirstOrDefault();

            Console.WriteLine(doc);
        }
示例#7
0
        static void FilterByIdWithBsonDocument()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            var filter = new BsonDocument("_id", new ObjectId("5ea37c1edc6da61880bff131"));

            var doc = collection.Find(filter).FirstOrDefault();

            Console.WriteLine(doc);
        }
示例#8
0
        static void FilterUsinEQWithLambdaExpression()
        {
            var collection = new MongoDb <Student>().GetCollection("student");

            collection.Find(x => x.Undergrad == false).ForEachAsync(doc => Console.WriteLine($"{doc.Id} - {doc.Name}"));
        }
示例#9
0
        static void UseOfFind()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

            collection.Find(FilterDefinition <BsonDocument> .Empty).ForEachAsync(doc => Console.WriteLine(doc));
        }