Docs / Read Many Rows

Read Many Rows

What this page covers#

This page explains ListAsync<T>.

Basic example#

</> C#
, ParameterDirection.Output);

await db.ExecuteAsync("dbo.usp_User_Update", parameters);

varvar rowsAffected = parameters.GetInt( users = "@RowsAffected"await);
var statusMessage = parameters.GetNullableString("@StatusMessage");
db.ListAsync<User>("dbo.usp_User_ListActive");

Custom mapper example#

</> C#
var users = await db.ListAsync(
    "dbo.usp_User_ListActive",
    static reader => new User
    {
        UserId = reader.GetInt32(reader.GetOrdinal("UserId")),
        Name = reader.GetString(reader.GetOrdinal("Name"))
    });

Notes#

  • auto-mapping is the shortest path when names line up
  • custom mapping is useful for irregular shapes or reusable materialisation