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

Add | Add RowsCopied64 property, refs, and docs #2004

Merged
merged 3 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,37 @@ and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
property.
</value>
<remarks>
<format type="text/markdown"><![CDATA[
<format type="text/markdown">
<![CDATA[

## Remarks
This value is incremented during the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event and does not imply that this number of rows has been sent to the server or committed.

This value can be accessed during or after the execution of a bulk copy operation.

This value will wrap around and become negative if the number of rows exceeds int.MaxValue. Consider using the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied64> property.
]]></format>
</remarks>
</RowsCopied>
<RowsCopied64>
<summary>
The number of rows processed in the ongoing bulk copy operation.
</summary>
<value>
The long value of the <see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied64" /> property.
</value>
<remarks>
<format type="text/markdown">
<![CDATA[

## Remarks
This value is incremented during the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event and does not imply that this number of rows has been sent to the server or committed.

This value can be accessed during or after the execution of a bulk copy operation.
]]>
</format>
</remarks>
</RowsCopied64>
<System.IDisposable.Dispose>
<summary>
Releases all resources used by the current instance of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public SqlBulkCopy(string connectionString, Microsoft.Data.SqlClient.SqlBulkCopy
public int NotifyAfter { get { throw null; } set { } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied/*'/>
public int RowsCopied { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied64/*'/>
public long RowsCopied64 { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/SqlRowsCopied/*'/>
public event Microsoft.Data.SqlClient.SqlRowsCopiedEventHandler SqlRowsCopied { add { } remove { } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/Close/*'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public SourceColumnMetadata(ValueMethod method, bool isSqlType, bool isDataFeed)
private readonly SqlBulkCopyOptions _copyOptions;
private int _timeout = DefaultCommandTimeout;
private string _destinationTableName;
private int _rowsCopied;
private long _rowsCopied;
private int _notifyAfter;
private int _rowsUntilNotification;
private bool _insideRowsCopiedEvent;
Expand Down Expand Up @@ -222,8 +222,8 @@ private int RowNumber
private TdsParserStateObject _stateObj;
private List<_ColumnMapping> _sortedColumnMappings;

private static int _objectTypeCount; // EventSource Counter
internal readonly int _objectID = Interlocked.Increment(ref _objectTypeCount);
private static int s_objectTypeCount; // EventSource Counter
internal readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount);

// Newly added member variables for Async modification, m = member variable to bcp.
private int _savedBatchSize = 0; // Save the batchsize so that changes are not affected unexpectedly.
Expand Down Expand Up @@ -376,7 +376,10 @@ public int NotifyAfter
internal int ObjectID => _objectID;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied/*'/>
public int RowsCopied => _rowsCopied;
public int RowsCopied => unchecked((int)_rowsCopied);

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied64/*'/>
public long RowsCopied64 => _rowsCopied;

internal SqlStatistics Statistics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public SqlBulkCopy(string connectionString, Microsoft.Data.SqlClient.SqlBulkCopy
public int NotifyAfter { get { throw null; } set { } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied/*'/>
public int RowsCopied { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied64/*'/>
public long RowsCopied64 { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/SqlRowsCopied/*'/>
public event Microsoft.Data.SqlClient.SqlRowsCopiedEventHandler SqlRowsCopied { add { } remove { } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/Close/*'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public SourceColumnMetadata(ValueMethod method, bool isSqlType, bool isDataFeed)
private readonly SqlBulkCopyOptions _copyOptions;
private int _timeout = DefaultCommandTimeout;
private string _destinationTableName;
private int _rowsCopied;
private long _rowsCopied;
private int _notifyAfter;
private int _rowsUntilNotification;
private bool _insideRowsCopiedEvent;
Expand Down Expand Up @@ -238,8 +238,8 @@ private int RowNumber
private TdsParserStateObject _stateObj;
private List<_ColumnMapping> _sortedColumnMappings;

private static int _objectTypeCount; // EventSource Counter
internal readonly int _objectID = Interlocked.Increment(ref _objectTypeCount);
private static int s_objectTypeCount; // EventSource Counter
internal readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount);

// Newly added member variables for Async modification, m = member variable to bcp.
private int _savedBatchSize = 0; // Save the batchsize so that changes are not affected unexpectedly.
Expand Down Expand Up @@ -392,7 +392,10 @@ public int NotifyAfter
internal int ObjectID => _objectID;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied/*'/>
public int RowsCopied => _rowsCopied;
public int RowsCopied => unchecked((int)_rowsCopied);

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopy.xml' path='docs/members[@name="SqlBulkCopy"]/RowsCopied64/*'/>
public long RowsCopied64 => _rowsCopied;

internal SqlStatistics Statistics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,19 @@ namespace Microsoft.Data.SqlClient
public class SqlRowsCopiedEventArgs : System.EventArgs
{
private bool _abort;
private long _rowsCopied;
private readonly long _rowsCopied;

/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml' path='docs/members[@name="SqlRowsCopiedEventArgs"]/ctor/*' />
public SqlRowsCopiedEventArgs(long rowsCopied)
{
_rowsCopied = rowsCopied;
}
public SqlRowsCopiedEventArgs(long rowsCopied) => _rowsCopied = rowsCopied;

/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml' path='docs/members[@name="SqlRowsCopiedEventArgs"]/Abort/*' />
public bool Abort
{
get
{
return _abort;
}
set
{
_abort = value;
}
get => _abort;
set => _abort = value;
}

/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml' path='docs/members[@name="SqlRowsCopiedEventArgs"]/RowsCopied/*' />
public long RowsCopied
{
get
{
return _rowsCopied;
}
}
public long RowsCopied => unchecked((int)_rowsCopied);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static void Test(string srcConstr, string dstConstr, string dstTable)
bulkcopy.WriteToServer(reader);

DataTestUtility.AssertEqualsWithDescription(bulkcopy.RowsCopied, 5, "Unexpected number of rows.");
DataTestUtility.AssertEqualsWithDescription(bulkcopy.RowsCopied64, (long)5, "Unexpected number of rows.");
}
Helpers.VerifyResults(dstConn, dstTable, 3, 5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private static async Task TestAsync(string srcConstr, string dstConstr, string d
await outputSemaphore.WaitAsync();

DataTestUtility.AssertEqualsWithDescription(bulkcopy.RowsCopied, 5, "Unexpected number of rows.");
DataTestUtility.AssertEqualsWithDescription(bulkcopy.RowsCopied64, (long)5, "Unexpected number of rows.");
}
Helpers.VerifyResults(dstConn, dstTable, 3, 5);
}
Expand Down