0
respostas

Não esta incluindo os Livros

Olá professor reparei que o meu não esta incluindo os livros. o valor recebido fica null.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver;

namespace ExemplosMongoDB
{
    public class ManipulandoClassesExternas
    {

        static void Main(string[] args)
        {
            Task T = MainASync(args);
            Console.WriteLine("Precione a tecla ENTER ");
            Console.ReadLine();
        }
        static async Task MainASync(string[] args)
        {


            Livro livro = new Livro();
            livro.Titulo = "Star Wars Legends";
            livro.Autor = "Timothy Zahn";
            livro.Ano = 2010;
            livro.Paginas = 245;
            List<string> lista_Assuntos = new List<string>();
            lista_Assuntos.Add("Ficção Cientifica");
            lista_Assuntos.Add("Ação");
            livro.Assunto= lista_Assuntos;



            //var doc = new BsonDocument();
            //doc.Add("Titulo", "Guerra dos Tronos");
            //doc.Add("Autor", "George R R Martin");
            //doc.Add("Ano", 1999);
            //doc.Add("Paginas", 886);


            //var assuntoArray = new BsonArray();

            //assuntoArray.Add("Fantasia");

            //assuntoArray.Add("Ação");
            //doc.Add("Assunto", assuntoArray);


            //Console.WriteLine(doc);


            //Console.WriteLine("Esperando 10 segundos....");
            //await Task.Delay(10000);

            //Console.WriteLine("Esperei 10 segundos....");

            var conexaobliblioteca =  new ConectandoMondoDB();


            await conexaobliblioteca.Livros.InsertOneAsync(livro);
            Console.WriteLine("Documento Incluido");
        }


    }
}

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software