Aggregate with Sort - MongoDB

1

I have a query in MongoDB, I do the aggregate to count how many items there are in each category, everything works fine, however I can not sort the data, which would be sorted by the Title field. Here is the code, in which I have already made numerous changes:

var aggregate = collection.Aggregate()
            .Match(filters)
            .Group(new BsonDocument { { "_id", "$CategoryId" }, { "count", new BsonDocument("$sum", 1) } })
            .Sort(new BsonDocument("Title", 1));
            //.Project(new BsonDocument { { "Title", 1 }, { "count", 1 } });
    
asked by anonymous 19.01.2016 / 14:47

0 answers