1

I know bulk operations can be done like this:

var upsertOne = new UpdateOneModel<BsonDocument>(filter, update) { IsUpsert = true };
bulkOps.Add(upsertOne);
collection.BulkWrite(bulkOps);

(source: https://stackoverflow.com/a/35688613/8344202)

But is it also possible to update two different collections in one bulk operation?

// Entity of CollectionA
bulkOps.Add(new UpdateOneModel<MyClassA>(filter, update) { IsUpsert = true });

// Entity of CollectionB 
bulkOps.Add(new UpdateOneModel<MyClassB>(filter, update) { IsUpsert = true });
collection.BulkWrite(bulkOps);

Many thanks in advance

Mathias
  • 1,819
  • 4
  • 22
  • 34

0 Answers0