var collection = database.GetCollection<Publication>("Publications");
var result = collection.InsertBatch(bookCollection);
我想獲取受影響的文檔數。並且我將AffectedDocumentCount設置爲零。MongoDB C#驅動程序 - InsertBatch獲取受影響的文檔數
什麼可能是錯的,有什麼想法?
var collection = database.GetCollection<Publication>("Publications");
var result = collection.InsertBatch(bookCollection);
我想獲取受影響的文檔數。並且我將AffectedDocumentCount設置爲零。MongoDB C#驅動程序 - InsertBatch獲取受影響的文檔數
什麼可能是錯的,有什麼想法?
看簽名:
IEnumerable<SafeModeResult> InsertBatch(
Type nominalType,
IEnumerable<Object> documents,
SafeMode safeMode
SafeMode可能導致推遲你真正批量寫入。玩FSyncTrue
(可以很慢)或True
。
服務器僅提供更新操作中受影響文檔數的計數。
WriteConcernResult的DocumentsAffected屬性來自對getLastErrorCommand的響應的「n」字段,該字段的Insert值始終爲0。