Save Galley!
I'm working with C # MongoDB .Net Driver, and have something I'm not understanding in the queries, follow the example:
var dataBase = mongoClient.GetDatabase(dbName);
var transactionsColl = dataBase.GetCollection<BsonDocument>(transactionCollectionName);
var mongoSales = transactionsColl.Aggregate()
.Match(BsonDocument.Parse("{ 'saleDate': { $lte: ISODate('" + timeStamp.ToString("o") + "') } }"))
.Group(new BsonDocument { { "_id", "$saleId" }, { "_documentObjId", "$_id" } }).ToListAsync().Result;
In grouping I have { "_id", "$saleId" }
and { "_documentObjId", "$_id" }
, error is in "_documentObjId"
, causes the following exception:
{"Command aggregate failed: the group aggregate field '_documentObjId' must be defined as an expression inside an object."}
I had understood that I could put any name as property of the document, but the error is not so simple, even in "_id"
if I change to any other name the same error, where do I make this definition?
Thanks!