0

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";
sqlBC.WriteToServer(dtOppConSummary);
}

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

2 Answers 2

1

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.
Sign up to request clarification or add additional context in comments.

Comments

0

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.

4 Comments

Ok can i replace the sql connection object with data access block??
or this is the best way to handle this??
I guess I should have asked why you are keen to try and use the data access block anyway... I'm not sure that you want to be using the data access block for this - you're using a SQL Server specific feature, so any benefit of going through the data access block is gone...
actually other my other code i have converted to DAAB and this is the only piece of code left and hence i had posted this query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.