-
Notifications
You must be signed in to change notification settings - Fork 299
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
Give SqlBulkCopy._rowsCopied a public getter #404
Comments
Hi @stylesm Thanks for the suggestion. Could you elaborate more on your use-case and is there a limitation in |
We're waiting for your response to move forward with the PR. Best Regards! |
@cheenamalhotra I might not be fully informed here; however, I think the purpose of exposing this property is so the author does not have to handle the It could be argued that under the current setup (the property being private), one could set the NotifyAfter property to something arbitrarily high in order to avoid multiple events being fired (from a performance point of view); although, this does seem somewhat of a non-optimal way of accomplishing the authors stated goals. I'd imagine the user story to be something like this:
|
We're on the same page, and that's the reason we're holding up on this one. There are many complaints about the But why would anyone use reflection is what I'm willing to hear. Is it just ease of code or limitation of |
@cheenamalhotra I'd imagine that they use reflection after the BulkCopy process rather than having to incur a performance hit of handling the events during the copy process. In other words, they don't care about tracking the progress; they just want to know at the end of the routine how many rows were copied. Absent of handling the event, and storing the outcome, the best way to do this is through accessing the property by way of reflection (from what I understand). |
@cheenamalhotra - thank you for pushing this fix on v2.0. This is quite an important property exposure for |
Is your feature request related to a problem? Please describe.
SqlBulkCopy
has a private member field for the number of rows copied (_rowsCopied
), which is incremented with each record copy operation. Currently, to make use of this in client code, the solution is either to use theSqlRowsCopiedEventHandler
(cumbersome and potentially expensive); or use reflection to get the value out of the private member field (hacky).Describe the solution you'd like
Create a public property backed by
_rowsCopied
with a public getter -SqlBulkCopy.RowsCopied { get { return _rowsCopied; } }
.Or replace
_rowsCopied
with a public property with a public getter -SqlBulkCopy.RowsCopied { get; }
Describe alternatives you've considered
The
SqlRowsCopiedEventHandler
; using reflection to get the value out of the private member field; doing a SQLCOUNT()
before and after copying.Additional context
Doesn't make sense to me to have a setter method for this property, but open to anyone's justification for it they think there should be!
Class in question: https://github.com/dotnet/SqlClient/blob/master/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
The text was updated successfully, but these errors were encountered: