Example #1
0
        protected CommandResult SaveEnumerable(IEnumerable <object> models)
        {
            try
            {
                var list = new BulkPersist(true, false, models);
                var body = list.ToString();

                var result  = Post(body);
                var updates = result.GetResultAs <SaveResponse[]>().ToDictionary(x => x.Id, x => x.Revision);
                models
                .ForEach(x =>
                {
                    var documentId = x.GetDocumentIdAsJson();
                    string newRev  = null;
                    if (updates.TryGetValue(documentId, out newRev))
                    {
                        x.SetDocumentRevision(newRev);
                    }
                });
                return(result);
            }
            catch (Exception ex)
            {
                throw Exception(
                          ex,
                          "An exception occurred trying to save a collection documents at {0}. \r\n\t {1}",
                          Uri.ToString(),
                          ex
                          );
            }
        }
Example #2
0
        protected static bool BulkPersistMatch(BulkPersist p)
        {
            var o = p.Documents[0] as TestDocument;

            return(o.DocumentId == id &&
                   o.Message == "Hello" &&
                   o.DocumentRevision == "2");
        }