SQL Bulkcopy using DATA Access block
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:
- Create an `IDbBulkCopy interface
- Create a wrapper class that implements the `IDbBulkCopy interface and wraps SqlBulkCopy
- 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.
精彩评论