Docs / Read Many Rows

Read Many Rows

What this page covers#

This page explains ListAsync<T>.

Basic example#

</> C#
)),
        Name = reader.GetString(reader.GetOrdinal("Name"))
    };
}

var users = awaitvar db.ListAsync("dbo.usp_User_ListActive", UserMap.Map);
var user = await db.SingleAsync("dbo.usp_User_GetById" users = , UserMap.Map, newawait MooParams().AddInt("@UserId", 42));
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