public IEnumerable <T> FindAuditRecords <T>(IAuditRecordStrategy <T> strategy) { using (Folder logFolder = Folder.Bind(this.storeSession, this.LogFolderId)) { foreach (T result in AuditLog.InternalFindAuditRecords <T>(logFolder, strategy)) { yield return(result); } } yield break; }
private static IEnumerable <T> InternalFindAuditRecords <T>(Folder logFolder, IAuditRecordStrategy <T> strategy) { using (QueryResult queryResults = logFolder.ItemQuery(ItemQueryType.None, null, strategy.QuerySortOrder, strategy.Columns)) { queryResults.SeekToOffset(SeekReference.OriginBeginning, 0); bool theEnd = false; while (!theEnd) { object[][] rows = queryResults.GetRows(1000); if (rows.Length <= 0) { break; } foreach (object[] row in rows) { AuditLog.RowPropertyBag rowAsPropertyBag = new AuditLog.RowPropertyBag(strategy.Columns, row); bool stopNow; bool match = strategy.RecordFilter(rowAsPropertyBag, out stopNow); if (stopNow) { theEnd = true; break; } if (match) { yield return(strategy.Convert(rowAsPropertyBag)); } } } } yield break; }