我正试图使用RenameCollectionOperation()在MongoDB中重命名一个集合。我找到了它的文档,但是我无法让它起作用。
private readonly MongoClient _mongoClient = new MongoClient("connectionString");
public IMongoCOllection<RenameCollection> ToRenameCollection => _MognoClient.GetDatabase().GetCollection<RenameCollection>("RrenameCollection");
var checkIfCollectionExists = ToRenameCollection.Find(new BsonDocument());
if (checkIfCollectionExists != null)
{
var test = new MongoDB.Driver.Core.Operations.RenameCollectionOperation(
new CollectionNamespace("database", "RrenameCollection"),
new CollectionNamespace("database", "RenameCollection"),
new MessageEncoderSettings()
);
}