Using Dapper, how do I pass in the values for a sql type as param?

北城以北 提交于 2019-12-02 10:25:18

You can pass DataTable for proper result. You can try the code below;

var dt = new DataTable();
dt.Columns.Add(new DataColumn("BrandID", typeof(int)));
foreach (var id in brandIDSet)
{
    var row = dt.NewRow();
    row["BrandId"] = id;
    dt.Rows.Add(row);
}

string storedProcName = "dbo.usp_getFilteredCatalogItems";
paginatedItemsVM.CatalogItemResults = await connection.QueryAsync<CatalogItemVM>(storedProcName, new { BrandIDSet = dt }, commandType: CommandType.StoredProcedure);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!