0

I have a cycle. It updated items.

var update = Builders<Profile>.Update.Set(p => p.MailLists, p2l.ToArray());
var query = Builders<Profile>.Filter.Eq(p => p.ID, new ObjectId(profileId));    
dbCollection.UpdateOneAsync(query, update).Wait();

For 10K items I have not updated 1-4. But I don`t get any error. If I done an update two times in a row, then it will work. What could it be? MongoDB.Driver version="2.0.1"

Veronika Kostenko
  • 265
  • 1
  • 2
  • 13
  • Does the process by which you created the object called `query` contain a step that looks something like `.skip(4)`? – Lori Mar 24 '16 at 15:39
  • No. That all: var update = Builders.Update.Set(p => p.MailLists, p2l.ToArray()); var query = Builders.Filter.Eq(p => p.ID, new ObjectId(profileId)); – Veronika Kostenko Mar 24 '16 at 15:43
  • If you are iterating a large amount of items to issue updates then you should be using "Bulk" operations instead. See [How to increase performance of the update operation in Mongo?](http://stackoverflow.com/questions/36130102/how-to-increase-performance-of-the-update-operation-in-mongo/36191579#36191579). It's unclear what the cause here is except that it's likely an error that you are not checking for anywhere. Also using `.Wait()` with an async operation is silly since you are effectively making this a synchronous and locked call. Better to use `yield` and actually check the `WriteResult` – Blakes Seven Mar 24 '16 at 23:51

0 Answers0