Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to pass options to SqlBulkCopy for bulk insert #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RedDeathGitHub
Copy link

Hi!

This is my first contribution, so apologies if this is not done right.
I find the library very useful, but I need to pass specific options to SqlBulkCopy when doing bulk insert.
So I created this fork to showcase my changes and ask if you find them useful to merge into the main library.

I tried to do this as a non-breaking change, so my additional parameters are all optional - this should not break existing code.
All tests seem to pass on my local machine.

Please let me know if you find this a worth-while addition, and please update the nuget version so I would be able to use these changes.
Alternatively I'll just use this as a local file library.

Cheers!

…al parameters - transaction and copy options.
@@ -56,7 +56,9 @@ public void InsertItems<T>(IEnumerable<T> items, string schema, string tableName
{
con.Open();
}
using (SqlBulkCopy copy = new SqlBulkCopy(con))
using (var copy = transaction == null
? new SqlBulkCopy(con.ConnectionString, copyOptions)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overloads for SqlBulkCopy are a bit weird, I have to use a string connection here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant