I've asked this on StackOverflow but I think this might be a better place:
I am having difficulty batch saving MongoDB documents using the C# driver. Here's sample code that inserts a Document with a GUID BsonID. Saving one at a time works. If I insert the documents into a list and use the save command it fails with an "Save can only be used with documents that have an Id."error. I think it might be a bug in the driver not recognizing the custom ID field, bu I am not sure. Any thoughts?
var autolookuplist = new List<BsonDocument>(); Parallel.ForEach(docs, webdoc => { lock (autolookuplist) { autoID++; var hold = new APAUtoIDGuidLookup() {AutoIncrementID = autoID, ID = webdoc.ID}; autolookuplist.Add(hold.ToBsonDocument()); } //this works // idcollection.Save(new APAUtoIDGuidLookup() { AutoIncrementID = autoID, ID = webdoc.ID }); }); //this doesn't work idcollection.Save(autolookuplist);here's the document class
public class APAUtoIDGuidLookup { [BsonId] public Guid ID { get; set; } public int AutoIncrementID { get; set; } }--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.