1
I have a query in Mongodb, I do Aggregate to count how many items there are in each category, everything works well, however I can’t sort the data, that would be ordered by the Title field. Follow the code, in which I’ve 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 } });
Already tried to put Sort after Group?
– Thiesen
yes, it’s changed several times, I ended up posting like this, I’ll even change.
– Junior S.