예제 #1
0
        protected virtual IEnumerable <T> RetrieveDocuments <T>(string docOrValue) where T : ICanJson, new()
        {
            var list = new List <T>();

            foreach (JToken row in Rows())
            {
                //var doc = new T();
                if (row[docOrValue] == null)
                {
                    continue;
                }
                var doc = JSonHelper <T> .ReadJSon(row[docOrValue].Value <JObject>());

                doc.ReadJson(row[docOrValue].Value <JObject>());
                list.Add(doc);
            }
            return(list);
        }
예제 #2
0
        /// <summary>
        /// Gets the document.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="documentId">The document identifier.</param>
        /// <returns>``0.</returns>
        public T GetDocument <T>(string documentId) where T : IBigDbDocument, new()
        {
            var doc = new T {
                Id = documentId
            };

            try
            {
                JObject obj = ReadDocumentJObject(documentId);
                doc = JSonHelper <T> .ReadJSon(obj);

                ReadDocument(doc);
            }
            catch (BigDNotFoundException)
            {
                return(default(T));
            }
            return(doc);
        }