var collection = database.GetCollection(tableName);
var aggregateFluent = collection.Aggregate();
var stages = new List
{
BsonDocument.Parse(“{ $unwind: ‘$ProductAttributeMappings’ }”),
BsonDocument.Parse("{ $match: { 'ProductAttributeMappings.AttributeControlTypeId': { $gt: 1 } } }"),
BsonDocument.Parse("{ $project: { column1 : '$ProductAttributeMappings.AttributeControlTypeId', column2: '$ProductAttributeMappings.IsRequired', '_id': 0 } }")
};
foreach (var stage in stages)
{
aggregateFluent = aggregateFluent.AppendStage(stage);
}
var result = await aggregateFluent.ToListAsync();
I want to pass this query. How to make stages dynamically