相关疑难解决方法(0)

我可以将列表传递给存储过程吗?

我有以下清单

ID | DESC | PRICE 
10 | SHOE | 5000
11 | LACE | 3000
12 | GAME | 2000
13 | TOAD | 3000
Run Code Online (Sandbox Code Playgroud)

我现在正在foreach循环中传递单个行,并且始终建立新连接,这看起来非常规,但我希望有更快的方法.

这是我的代码.

foreach(var item in tempList)
{
     using (connection)
     {
        SqlCommand command = new SqlComman("StoredProc", connection);
        command.Parameters.Add(new SqlParameter("id", item.id));
        command.Parameters.Add(new SqlParameter("desc", item.desc));
        command.Parameters.Add(new SqlParameter("price", item.price));
        ...
     }
}
Run Code Online (Sandbox Code Playgroud)

那么如何将列表传递给存储过程呢?

sql asp.net stored-procedures

2
推荐指数
1
解决办法
2681
查看次数

标签 统计

asp.net ×1

sql ×1

stored-procedures ×1