开发者

SQL Bulkcopy using DATA Access block

开发者 https://www.devze.com 2022-12-27 15:07 出处:网络
I am using the below piece of code for SQL Bulk copy using (SqlConnection con = new SqlConnection(strConString))

I am using the below piece of code for SQL Bulk copy

using (SqlConnection con = new SqlConnection(strConString))
{
con.Open();
SqlBulkCopy sqlBC = new SqlBulkCopy(con);
sqlBC.DestinationTableName = "SomeTable";
s开发者_如何学JAVAqlBC.WriteToServer(dtOppConSummary);
}

Can anyone provide me the equvalent code using Data access block Enterprise library


Unfortunately, there is not a bulk copy pattern out of the box with the DAAB. The SqlBulkCopy class does not implement any interfaces besides disposable.

If you want to use bulk copy in a DAAB environment, you will have to modify your DAAB implementation to include it. Some steps you'll have to take are:

  1. Create an `IDbBulkCopy interface
  2. Create a wrapper class that implements the `IDbBulkCopy interface and wraps SqlBulkCopy
  3. If you need access Oracle, implement the `IDbBulkCopy interface to use ADO.NET's "Array Binding" feature.


I'm not sure if that's going to be possible because the point of the data access block is to abstract you away from a specific data source. SqlBulkCopy if specific to the SqlClient libraries, and I don't think there's a generic way of doing this kind of operation across other data sources.

0

精彩评论

暂无评论...
验证码 换一张
取 消