Dapper 可以批处理一组存储过程调用吗?
Dapper 可以批量处理一组存储过程调用吗?我在文档中看到它支持多个结果,但我不确定是否可以使用 Dapper 执行多个存储过程调用。
Can Dapper batch a set of stored proc calls? I see it supports Multiple Results in the documentation but I'm not sure if you can execute multiple stored proc calls using Dapper.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Dapper 支持存储过程的批处理命令:
上面的代码重复使用 IDbCommand 和文本
#spInsert
3 次。这使得批量插入更加高效。一般来说,如果您担心此级别的性能,您会将批处理调用包装在事务中。
此外,Dapper 支持您决定发送的任何批次:
这将导致插入三行。
此外,如果
#spInsert
返回一个结果集,您可以使用QueryMultiple
执行批处理,这将为您提供 3 个记录集进行迭代。Dapper supports batching commands for stored procs:
The code above reuses the IDbCommand with the text
#spInsert
, 3 times. This makes batching inserts a bit more efficient.In general if you worry about perf at this level you would wrap the batch call in a transaction.
Additionally Dapper supports whatever batch you decide to send it:
Which would cause three rows to be inserted.
Further more, if
#spInsert
returned a result set you could useQueryMultiple
to execute the batch which would give you 3 record sets to iterate through.