Not Exists in MongoDB with C# 2.2.4 driver

NotExists will be used when you are going to retrieve the data which doesn’t have a specific node in the document. It can be used along with find Query while retrieving the data. Below Example is executed with MongoC# 2.2.4 driver.


using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Bson;
using MongoDB.Shared;
using MongoDB.Driver.Builders;

namespace MCNotexists
    public class Program
        static void Main(string[] args)
            string conString = "mongodb://ampleServiceQA:ampleServiceQAPassword@";
            var Client = new MongoClient(conString);
            var DB = Client.GetDatabase("ampleServiceQA");
            var query = Query<ample>.NotExists(u =>;
            var builder = Builders<BsonDocument>.Filter;
            var collection = DB.GetCollection<BsonDocument>("amplecollection");
            var filter = builder.Exists("style", false);
            var RetrievedData = collection.Find(filter).ToList();
            foreach (var doc in RetrievedData)

        public class ample
            public Style style { get; set; }
        public class Style
            public string description { get; set; }
            public string number { get; set; }