Exemplo n.º 1
0
        public JArray GetDocuments(int start, int pageSize, Guid? etag)
        {
            var list = new JArray();
            TransactionalStorage.Batch(actions =>
            {
                IEnumerable<JsonDocument> documents;
                if (etag == null)
                    documents = actions.Documents.GetDocumentsByReverseUpdateOrder(start);
                else
                    documents = actions.Documents.GetDocumentsAfter(etag.Value);
                var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
                foreach (var doc in documents.Take(pageSize))
                {
                    var document = documentRetriever.ExecuteReadTriggers(doc, null,
						// here we want to have the Load semantic, not Query, because we need this to be
						// as close as possible to the full database contents
						ReadOperation.Load); 
                    if (document == null)
                        continue;
                    if (document.Metadata.Property("@id") == null)
                        document.Metadata.Add("@id", new JValue(doc.Key));

                    list.Add(document.ToJson());
                }
            });
            return list;
        }
Exemplo n.º 2
0
        public JArray GetDocuments(int start, int pageSize, Guid? etag)
        {
            var list = new JArray();
            TransactionalStorage.Batch(actions =>
            {
                IEnumerable<JsonDocument> documents;
                if (etag == null)
                    documents = actions.Documents.GetDocumentsByReverseUpdateOrder(start);
                else
                    documents = actions.Documents.GetDocumentsAfter(etag.Value);
                var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
                foreach (var doc in documents.Take(pageSize))
                {
                    var document = documentRetriever.ExecuteReadTriggers(doc, null, ReadOperation.Query);
                    if (document == null)
                        continue;
                    if (document.Metadata.Property("@id") == null)
                        document.Metadata.Add("@id", new JValue(doc.Key));

                    list.Add(document.ToJson());
                }
            });
            return list;
        }