Read Multiple Result Sets
What this page covers#
This page shows how to use QueryMultipleAsync(...).
Example#
public sealed class DashboardResult { public User? User { get; init; } public IReadOnlyList<Notification> Notifications { get; init; } = []; public int PendingCount { get; init; } } var result = await db.QueryMultipleAsync( "dbo.usp_Dashboard_Get", results => new DashboardResult { User = results.Single<User>(), Notifications = results.List<Notification>(), PendingCount = results.Scalar<int>() }, new MooParams() .AddInt("@UserId", 42));
Important notes#
- reads happen sequentially
- each call consumes the next result set
- you cannot revisit a result set
- reading too far throws