Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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}"));
        }
Exemplo n.º 9
0
        static void UseOfFind()
        {
            var collection = new MongoDb <BsonDocument>().GetCollection("student");

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