Я видел здесь примеры людей, делающих то же самое, но по какой-то причине я получаю ошибку.
IMongoDatabase db = Globals.gdbSourceDB.GetDatabase(Globals.gsWatchDatabase);
ChangeStreamOptions options = new ChangeStreamOptions() { FullDocument = ChangeStreamFullDocumentOption.UpdateLookup };
var pipeline = new EmptyPipelineDefinition<ChangeStreamDocument<BsonDocument>>().Match("{ operationType: { $in: [ 'replace', 'insert', 'update', 'delete' ] } }");
var changeStream = db.Watch(pipeline, options).ToEnumerable().GetEnumerator();
while (changeStream.MoveNext())
{
ChangeStreamDocument<BsonDocument> next = changeStream.Current;
IMongoDatabase dbDest;
IMongoCollection<BsonDocument> colDest;
dbDest = Globals.gdbDestDB.GetDatabase(Globals.gsWatchDatabase);
colDest = dbDest.GetCollection<BsonDocument>(next.CollectionNamespace.CollectionName);
if (next.OperationType.ToString() == "Delete")
{
//Delete the same record
var retDel = colDest.DeleteOne(a => a.Id == next.DocumentKey);
}
}
Я знаю, next.DocumentKey
не совсем правильно, но проблема в. Ид. Я получаю следующую ошибку:
Ошибка CS1061 «BsonDocument» не содержит определения «Id», и доступный метод расширения «Id», принимающий первый аргумент типа «BsonDocument», не может быть найдено (вам не хватает директивы using или ссылки на сборку?)
Что я делаю не так? Спасибо!