Reputation: 249
When using the commands as below, it returning null.
var pipeline = new BsonDocument[] {
new BsonDocument{{"$group", new BsonDocument{{"_id", "$BrandId"}}}}
};
var brands = context
.Items.Aggregate<BsonDocument>(pipeline);
Data ex:
The Aggregation method I have as shown below:
Upvotes: 0
Views: 415
Reputation: 2516
It seems that all you are missing is doing a ToList() or ToListAsync() after the Aggregate()
call to make it return the data.
Is there a reason you are not using the Group method instead?
Aggregate().Group(new BsonDocument() { "_id" : "$BrandId"})
Upvotes: 1