-
Notifications
You must be signed in to change notification settings - Fork 317
Closed
Description
It is is difficult to find out how many rows SqlBulkCopy.WriteToServer[Async] has copied. This is a problem when using streaming as DbDataReader doesn't provide this information either.
Describe the solution you'd like
class SqlBulkCopy
{
...
public long RowsCopied { get; }
...
}
It would be cleaner to change the return type of WriteToServer[Async] to long, but I think this would technically be a breaking change? This would also have the advantage of not having to worry about multiple calls or reads before writing.
Describe alternatives you've considered
- setting
NotifyAfterto 1, subscribing toSqlRowsCopiedand then storing it somewhere from the event handler. Cons: overhead of calling a delegate, plus the allocation ofEventArgsper row. - fully buffer to a
DataTable. Cons: whole dataset in memory. - wrapping
IDataReaderand keeping count of the number of times Read() is called. Cons:
doesn't work for async readers. - wrapping
DbDataReader. Cons: lots of boilerplate, can't call protected methods on the source leading to unintended behaviour divergence. SELECT COUNT(*) FROM DESTINATION. Cons: network round trip, concurrency issues.- Reflecting on the private
_rowsCopiedfield. Cons: reflection, brittle.
Additional context
juliusfriedman
Metadata
Metadata
Assignees
Labels
No labels