private IEnumerable <Document> GetDocumentsEnumerator(DocumentsOperationContext databaseContext, string collection, long lastEtag, int pageSize) { if (collection == Constants.Documents.Collections.AllDocumentsCollection) { return(_documentsStorage.GetDocumentsFrom(databaseContext, lastEtag + 1, 0, pageSize)); } return(_documentsStorage.GetDocumentsFrom(databaseContext, collection, lastEtag + 1, 0, pageSize)); }
private IEnumerable <Document> GetDocumentsEnumerator(QueryOperationContext queryContext, string collection, long lastEtag, long pageSize) { if (collection == Constants.Documents.Collections.AllDocumentsCollection) { return(_documentsStorage.GetDocumentsFrom(queryContext.Documents, lastEtag + 1, 0, pageSize)); } return(_documentsStorage.GetDocumentsFrom(queryContext.Documents, collection, lastEtag + 1, 0, pageSize)); }
private IEnumerable <Document> GetDocuments() { IEnumerable <Document> documents; if (_startsWith != null) { if (_isAllDocsCollection) { documents = _documents.GetDocumentsStartingWith(_context, _startsWith, null, null, null, _start, _query.PageSize); } else { documents = _documents.GetDocumentsStartingWith(_context, _startsWith, null, null, null, _start, _query.PageSize, _collection); } } else if (_ids != null) { if (_ids.Count == 0) { documents = Enumerable.Empty <Document>(); } else { documents = _isAllDocsCollection ? _documents.GetDocuments(_context, _ids, _start, _query.PageSize, _totalResults) : _documents.GetDocuments(_context, _ids, _collection, _start, _query.PageSize, _totalResults); } } else if (_isAllDocsCollection) { documents = _documents.GetDocumentsFrom(_context, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetNumberOfDocuments(_context); } else { documents = _documents.GetDocumentsFrom(_context, _collection, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetCollection(_collection, _context).Count; } return(documents); }
private IEnumerable <Document> GetDocuments() { IEnumerable <Document> documents; if (_ids != null && _ids.Count > 0) { documents = _documents.GetDocuments(_context, _ids, _start, _query.PageSize, _totalResults); } else if (_isAllDocsCollection) { documents = _documents.GetDocumentsFrom(_context, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetNumberOfDocuments(_context); } else { documents = _documents.GetDocumentsFrom(_context, _collection, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetCollection(_collection, _context).Count; } return(ApplySorting(documents)); }
private IEnumerable <Document> GetDocuments() { IEnumerable <Document> documents; if (_startsWith != null) { var countQuery = false; if (_query.PageSize == 0) { countQuery = true; _query.PageSize = int.MaxValue; } if (_isAllDocsCollection) { documents = _documents.GetDocumentsStartingWith(_context, _startsWith, null, null, null, _start, _query.PageSize); } else { documents = _documents.GetDocumentsStartingWith(_context, _startsWith, null, null, null, _start, _query.PageSize, _collection); } if (countQuery) { foreach (var document in documents) { using (document.Data) _totalResults.Value++; } documents = Enumerable.Empty <Document>(); _query.PageSize = 0; } } else if (_ids != null) { if (_ids.Count == 0) { documents = Enumerable.Empty <Document>(); } else { documents = _isAllDocsCollection ? _documents.GetDocuments(_context, _ids, _start, _query.PageSize, _totalResults) : _documents.GetDocuments(_context, _ids, _collection, _start, _query.PageSize, _totalResults); } } else if (_isAllDocsCollection) { documents = _documents.GetDocumentsFrom(_context, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetNumberOfDocuments(_context); } else { documents = _documents.GetDocumentsFrom(_context, _collection, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetCollection(_collection, _context).Count; } return(documents); }
private IEnumerable <Document> GetDocuments() { IEnumerable <Document> documents; if (_startsWith != null) { var countQuery = false; if (_query.PageSize == 0) { countQuery = true; _query.PageSize = int.MaxValue; } documents = _isAllDocsCollection ? _documents.GetDocumentsStartingWith(_context, _startsWith, null, null, _startAfterId, _start, _query.PageSize, fields: _fields) : _documents.GetDocumentsStartingWith(_context, _startsWith, null, null, _startAfterId, _start, _query.PageSize, _collection, _fields); if (countQuery) { foreach (var document in documents) { using (document.Data) _totalResults.Value++; } documents = Enumerable.Empty <Document>(); _query.PageSize = 0; } } else if (_ids != null) { if (_ids.Count == 0) { documents = Enumerable.Empty <Document>(); } else if (_alreadySeenIdsCount != null) { var idsLeft = _ids.Count - _alreadySeenIdsCount.Value; if (idsLeft == 0) { documents = Enumerable.Empty <Document>(); } else { var count = idsLeft >= _query.PageSize ? _query.PageSize : idsLeft; var ids = _ids.Skip((int)_alreadySeenIdsCount.Value).Take((int)count); _alreadySeenIdsCount.Value += count; documents = _isAllDocsCollection ? _documents.GetDocuments(_context, ids, 0, _query.PageSize, _totalResults) : _documents.GetDocuments(_context, ids, _collection, 0, _query.PageSize, _totalResults); } } else { documents = _isAllDocsCollection ? _documents.GetDocuments(_context, _ids, _start, _query.PageSize, _totalResults) : _documents.GetDocuments(_context, _ids, _collection, _start, _query.PageSize, _totalResults); } } else if (_isAllDocsCollection) { documents = _documents.GetDocumentsFrom(_context, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetNumberOfDocuments(_context); } else { documents = _documents.GetDocumentsFrom(_context, _collection, 0, _start, _query.PageSize); _totalResults.Value = (int)_documents.GetCollection(_collection, _context).Count; } return(documents); }