Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Guides & Recipes — Auditing

Production recipes for querying large tenant audit logs with keyset continuation tokens and verifying cryptographic chains.

v2.0.0 replaced integer/ID cursor properties (AfterRecordId / NextCursorId) with opaque ContinuationToken and NextPageToken:

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Auditing;
namespace Example.AuditingRecipes;
public static class AuditLogReader
{
public static async Task<IReadOnlyList<AuditRecord>> ReadAllForOrderAsync(
IAuditStore store,
string tenantId,
string orderId,
CancellationToken ct)
{
var collected = new List<AuditRecord>();
string? token = null;
do
{
AuditQueryResult page = await store.QueryAsync(new AuditQuery
{
TenantId = new TenantId(tenantId),
ResourceType = "Order",
ResourceId = orderId,
PageSize = 100,
ContinuationToken = token
}, ct);
collected.AddRange(page.Records);
token = page.HasMore ? page.NextPageToken : null;
}
while (token is not null);
return collected;
}
}

For compliance exports that exceed single-page memory budgets, iterate await foreach (AuditRecord entry in store.StreamAsync(query, ct)) to stream rows directly from the underlying provider cursor without materializing all pages in memory.

When recording bulk administrative actions (e.g., permission sweeps), group records into an IReadOnlyList<AuditRecord> and call await store.AppendBatchAsync(batch, ct) so providers execute a single round-trip while preserving per-tenant chain order.