I'm trying to deserialize filter with LUUID (or NUUID in this example) to BsonDocument:
var tmpQry = "{'ValueId': NUUID('ca7ac84f-18bf-42f0-b028-333ed144c549')";
var tmpBson = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(tmpQry);
and getting an error:
System.FormatException: 'JSON reader was expecting a value but found 'NUUID'.'
I understand, that LUUID is not valid for JSON, but is it somehow possible to get BsonDocument from my string?
In my particular case i can't implement MongoDB nested $elemMatch query, like in this issue. But my query contains identifiers:
db.getCollection('my_db').aggregate([
{
$match: {
'Event.key_attributes': {
$all: [
{ '$elemMatch': { 'Type.Code': 'code1', 'ValueId': LUUID('00000000-0000-0000-0000-000000000001') } },
{ '$elemMatch': { 'Type.Code': 'code2', 'ValueId': LUUID("00000000-0000-0000-0000-000000000002") } },
{ '$elemMatch': { 'Type.Code': 'code3', 'ValueId': LUUID("00000000-0000-0000-0000-000000000003") } }
]
}
}
},
{
$group: {
'_id': '$$CURRENT.Event.type._id',
'code': { '$last': '$$CURRENT.Event.type.Code' },
'value': { '$sum': '$$CURRENT.Event.value' }
}
}
]);
, and I even can't deserialize it into a BsonDocument. Does my problem have any solution? Thanks a lot.