配置 ChangeStreamCursor 时不能使用 Mpipeline

问题描述 投票:0回答:0
var client = new MongoClient("<My connection string>");
var watchedDatabaseNames = new List<string> { "DB1", "DB2" };
var options = new ChangeStreamOptions { FullDocument = ChangeStreamFullDocumentOption.UpdateLookup };
var pipeline = new EmptyPipelineDefinition<ChangeStreamDocument<BsonDocument>>()
    .Match(change => watchedDatabaseNames.Contains(change.DatabaseNamespace.DatabaseName));
var cursor = client.Watch(pipeline, options);

Throws System.NotSupportedExceptions: 'Serializer for MongoDB.Driver.DatabaseNamespace 必须实现 IBsonDocumentSerializer 与 LINQ 一起使用'

在上面的最后一行。

我只是想收到变更流的通知,但仅限于某些数据库中的文档。 谁能帮帮我?

c# mongodb mongodb-.net-driver
© www.soinside.com 2019 - 2024. All rights reserved.