예제 #1
0
        static async void Run()
        {
            var connectionString = "mongodb://localhost";
            var dbName           = "books";
            var db = GetDatabase(connectionString, dbName);

            IRepository <Book> repo = new MongoDbRepository <Book>(db);

            var input = ReadInput();

            var patrickRothfuss = new Author(input[2], input[3]);
            await repo.Add(new Book(input[0], input[1], patrickRothfuss));

            (await repo.All())
            .ToList()
            .ForEach(Console.WriteLine);


            //Deleting
            var first = (await repo.All())
                        .FirstOrDefault();

            Console.WriteLine("Deleting {0}", first.Title);
            await repo.Delete(first);

            Console.WriteLine("{0} deleted", first.Title);
            Console.WriteLine("---------------");
            (await repo.All())
            .ToList()
            .ForEach(Console.WriteLine);
        }
예제 #2
0
        static async void Run()
        {
            var connectionString = "mongodb://localhost";
            var dbName = "books";
            var db = GetDatabase(connectionString, dbName);

            IRepository<Book> repo = new MongoDbRepository<Book>(db);

            var input = ReadInput();

            var patrickRothfuss = new Author(input[2], input[3]);
            await repo.Add(new Book(input[0], input[1], patrickRothfuss));

            (await repo.All())
                    .ToList()
                    .ForEach(Console.WriteLine);


            //Deleting
            var first = (await repo.All())
                    .FirstOrDefault();

            Console.WriteLine("Deleting {0}", first.Title);
            await repo.Delete(first);

            Console.WriteLine("{0} deleted", first.Title);
            Console.WriteLine("---------------");
            (await repo.All())
                    .ToList()
                    .ForEach(Console.WriteLine);
        }
예제 #3
0
        public void TestGet()
        {
            var client = new MongoClient(MongoDbConnectionString);


            IRepository <STUResponse> repo = new MongoDbRepository <STUResponse>(client, DatabaseName);
            List <STUResponse>        resp = repo.All(p => p.IntentType == "HowIsSTU").ToList();
        }
예제 #4
0
 public void SelectingProductsFromMongoIsNotThrowingExeption()
 {
     Assert.DoesNotThrow(() => { _mongo.All <Product>().Count(); });
 }