I have the following code:
PipelineDefinitionBuilder.Match<BsonDocument, BsonDocument>(myPipeline, Builders<BsonDocument>.Filter.Eq("$_id", "$$userId"));
I expect the generated BsonDocument to be:
{{
{ "$eq": ["$_id", "$$userId"] }}}
Instead I get this:
{{
{ "$_id": "$$userId" }}}
Which results in the aggregation command to fail with error:
Command aggregate failed: unknown top level operator: $_id
Other filters seems to work as expected. e.g
PipelineDefinitionBuilder.Match<BsonDocument, BsonDocument>(myPipeline, Builders<BsonDocument>.Filter.Gt("$var1", "$$var2"));
Generates:
{{
{ "$gt": ["$var1", "$$var2"] }}}