Exemple #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);
        }
Exemple #2
0
 public Book(string title, string isbn, Author patrickRothfuss)
 {
     this.Title = title;
     this.ISBN = isbn;
     this.Author = patrickRothfuss;
 }
Exemple #3
0
 public Book(string title, string isbn, Author patrickRothfuss)
 {
     this.Title  = title;
     this.ISBN   = isbn;
     this.Author = patrickRothfuss;
 }