Aggregate in C # does not return anything?

1

I made a direct query on the console that returned what I expected, the query on the mongo is like this.

db.AtividadeResultMongo.aggregate([{$unwind: "$LsVariaveisProcesso"},
    {$match: {
        IdAtividade : 913,
        IdEstadoInstanciaAtividade : 6,
        LsVariaveisProcesso : { $regex : /^idato/i }
    }},
    {$project: {
        LsVariaveisProcesso: 1
    }},
    {$group: { _id: "$LsVariaveisProcesso" }},
    {$count: "total"}])

When I run the total return: 113 that is correct, it has values in the base, however in C# does not return anything and I need help putting it in there c #, can anyone help me?

I tried to start like this

var agg = ObterCollection("AtividadeResultMongo")
          .Aggregate()
          .Match(new BsonDocument { 
            { "IdAtividade", "913" }, 
            { "IdEstadoInstanciaAtividade", "6" } });

var teste = await agg.ToListAsync();

But in the test variable there is nothing, the connection is correct with the base is correct, I ran a count and returned value

ObterCollection("AtividadeResultMongo")
       .AsQueryable()
       .Count()
    
asked by anonymous 01.09.2017 / 23:26

0 answers