public bool FindDocument(string name, string colname, out JSONDocument doc) { bool found = false; IList <IJSONDocument> jsonDocuments = new List <IJSONDocument>(); doc = new JSONDocument(); if (name != null) { doc.Key = name.ToLower(); jsonDocuments.Add(doc); IGetOperation getOperation = new GetDocumentsOperation(); getOperation.Database = MiscUtil.SYSTEM_DATABASE; getOperation.Collection = colname; getOperation.DocumentIds = jsonDocuments; IGetResponse response = _store.GetDocuments(getOperation); IDataChunk dataChunk = response.DataChunk; if (dataChunk.Documents.Count != 0) { doc = dataChunk.Documents[0] as JSONDocument; found = true; } else { doc = null; found = false; } } return(found); }
public ICollectionReader GetDocuments(ICollection<string> documentKeys) { if (documentKeys == null) throw new ArgumentNullException("documentKeys"); if (documentKeys.Count < 1) throw new ArgumentException("No DocumentKey specified"); List<JSONDocument> documents = new List<JSONDocument>(); foreach (string documentKey in documentKeys) { if (documentKey != null) { JSONDocument jdoc = new JSONDocument(); jdoc.Key = documentKey; documents.Add(jdoc); } } GetDocumentsOperation getDocumentsOperation = new GetDocumentsOperation(); getDocumentsOperation.DocumentIds = documents.Cast<IJSONDocument>().ToList(); getDocumentsOperation.Database = _database.DatabaseName; getDocumentsOperation.Collection = _collectionName; GetDocumentsResponse getDocumentsResponse = (GetDocumentsResponse)_database.ExecutionMapper.GetDocuments(getDocumentsOperation); if (getDocumentsResponse.IsSuccessfull) { CollectionReader reader = new CollectionReader((DataChunk)getDocumentsResponse.DataChunk, _database.ExecutionMapper, _database.DatabaseName, _collectionName); return reader; } else throw new Exception("Operation failed Error: " + Common.ErrorHandling.ErrorMessages.GetErrorMessage(getDocumentsResponse.ErrorCode, getDocumentsResponse.ErrorParams)); }