[CSHARP-3566] Allow the use of bsonsize in the c# driver Created: 12/Apr/21 Updated: 27/Oct/23 Resolved: 13/Apr/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Hugh Walsh | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I am using a multi tenant database and we would like to divide up the costs based on storage. To find out the amount of data i would like to make use of the bsonsize group operator.
With the C# code var match = new BsonDocument Unknown macro: {
"_id.DesignId", new BsonBinaryData(designId, GuidRepresentation.Standard)
}
} Unknown macro: {
{ "_id", BsonNull.Value }
, Unknown macro: { "$bsonSize", "$$ROOT" }
} }, var result = collection.Aggregate(PipelineDefinition<T, BsonDocument>.Create(match, group)).ToEnumerable().ToList();
I get the error:
|
| Comments |
| Comment by Dmitry Lukyanov (Inactive) [ 13/Apr/21 ] | ||||||||||||
|
Hello hugh.walsh@romaxtech.com, since you're working with $group, you should also use $sum (group operator) as it's described here , so the below code should work for you:
| ||||||||||||
| Comment by Esha Bhargava [ 13/Apr/21 ] | ||||||||||||
|
hugh.walsh@romaxtech.com Thank you for reporting this issue! We'll look into it and get back to you soon. |