Details
Description
I have a collection named ResourceTypeCategory with documents containing a list of value object named Properties. I need the intersection of the persisted array with an input array (see below)
db.ResourceTypeCategoryRoot.aggregate([ { "$project" : { "intersect" : { "$setIntersection" : ["$Properties.Acronym", ["ROY", "MAJ"]] } } } ]);
|
If i run this command on mongod shell it works fine but if i use the mongodb csharp driver method "Aggregate" in "Collection" class of official mongodbcsharpdriver i get this error:
"Command 'aggregate' failed: exception: invalid operator '$SetIntersection'"
This is my code:
var pipeline = new BsonDocument[]
|
{
|
new BsonDocument
|
{
|
{ "$project", new BsonDocument
|
{
|
{ "intersect", new BsonDocument
|
{
|
{ "$setIntersection", new BsonArray
|
{ "$Properties.Acronym",
|
new BsonArray(propertyIds.ToArray())
|
}
|
}
|
}
|
}
|
}
|
|
|
}
|
}
|
};
|
|
|
var test = collection.Aggregate(pipeline);
|
Help!