带有 SqlHelper 类的 SqlBulkCopy
我已安装 DataAccessApplicationBlock.msi
并将 Microsoft.ApplicationBlocks.Data.dll
文件放入我的 bin 文件夹中。我发现了除 ExecuteBulkCopy 之外的所有其他 sqlhelper 方法。
如何将 ExecuteBulkCopy 函数添加到 SqlHelper 类中?
I've installed DataAccessApplicationBlock.msi
and I got the Microsoft.ApplicationBlocks.Data.dll
file into my bin folder. I found every other sqlhelper methods except ExecuteBulkCopy
.
How do I add ExecuteBulkCopy
function to the SqlHelper
class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是对数据库的抽象吗?如果不是 SQL-Server,代码会做什么?我个人认为将其封装在通用(和数据库中立)库中没有意义。
还;这是非常基本的功能,因此您在为接受连接字符串、表名和
IDataReader
/DataTable
的基本场景编写方法时应该不会有任何问题。在重要的用途中,它有很多配置选项(列映射、事件等),并且可能不保证包装。老实说,虽然我使用
SqlBulkCopy
,但我使用它的频率不够(或类似地足够),不足以保证将其隐藏起来。也许只是直接在您的存储库/DAL/任何代码中使用SqlBulkCopy
?Isn't that block an abstraction over the database? What would the code do if it wasn't SQL-Server? I personally don't think it makes sense to encapsulate this in a general-purpose (and database-neutral) library.
Also; it is pretty basic functionality, so you shouldn't have any problem writing a method for the basic scenario that accepts a connection-string, table name, and
IDataReader
/DataTable
. In non-trivial usage is has lots of configuration options (column mapping, events, etc), and probably doesn't warrant wrapping.To be honest, while I use
SqlBulkCopy
, I don't use it often enough (or similarly enough) to warrant hiding it away. Perhaps just useSqlBulkCopy
directly in your repository / DAL / whatever code?