public IEnumerable <QueryRow> RegularQuery(QueryOptions options) { var optionsCopy = options.Copy(); // Needed because Count() and ElementAt() will share this var filter = optionsCopy.Filter; var limit = Int32.MaxValue; var skip = 0; if (filter != null) { // If a filter is present, these need to be applied to the filter // and not the query limit = optionsCopy.Limit; skip = optionsCopy.Skip; optionsCopy.Limit = Int32.MaxValue; optionsCopy.Skip = 0; } var enumerator = QueryEnumeratorWithOptions(optionsCopy); foreach (var next in enumerator) { var key = CouchbaseBridge.DeserializeKey <object>(next.Key); var value = (next.Value as IEnumerable <byte>).ToArray(); var docRevision = default(RevisionInternal); if (value.Length == 1 && value[0] == 42) { docRevision = _dbStorage.GetDocument(next.DocID, null, true); } else { docRevision = _dbStorage.GetDocument(next.DocID, null, optionsCopy.IncludeDocs); } var row = new QueryRow(next.DocID, next.DocSequence, key, value, docRevision, this); if (filter != null) { if (!filter(row)) { continue; } if (skip > 0) { skip--; continue; } if (limit-- == 0) { yield break; } } Log.To.Query.V(Tag, "Query {0} found row with key={1}, value={2}, id={3}", Name, new SecureLogJsonString(key, LogMessageSensitivity.PotentiallyInsecure), new SecureLogString(value, LogMessageSensitivity.PotentiallyInsecure), new SecureLogString(next.DocID, LogMessageSensitivity.PotentiallyInsecure)); yield return(row); } }