Skip to content

Give SqlBulkCopy._rowsCopied a public getter #404

@stylesm

Description

@stylesm

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 the SqlRowsCopiedEventHandler (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 SQL COUNT() 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement 💡Issues that are feature requests for the drivers we maintain.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions