MongoDBのJIRAに関する問題 によると ページでは、すぐに使用できる機能としてAPIから削除されました。
幸い、FindOptionsでクエリ修飾子を指定することで可能です。 :
var options = new FindOptions
{
Modifiers = new BsonDocument("$explain", true)
};
var explain = await collection.Find(x => true, options)
.Project(new BsonDocument())
.FirstOrDefault()
?.ToJson();
x => trueを置き換えるだけです プロファイルするクエリを使用します。 .ToJson()を追加しました 人間が読める形式のJSON文字列を取得するため。