You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
or reconnects to a different server due to failover.
264
+
</para>
265
+
</remarks>
266
+
</ClearCachedMetadata>
238
267
<EnableStreaming>
239
268
<summary>
240
269
Enables or disables a <seecref="T:Microsoft.Data.SqlClient.SqlBulkCopy" /> object to stream data from an <seecref="T:System.Data.IDataReader" /> object
Copy file name to clipboardExpand all lines: doc/snippets/Microsoft.Data.SqlClient/SqlBulkCopyOptions.xml
+41Lines changed: 41 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -68,5 +68,46 @@ To see how the option changes the way the bulk load works, run the sample with t
68
68
When specified, each batch of the bulk-copy operation will occur within a transaction. If you indicate this option and also provide a <seecref="T:Microsoft.Data.SqlClient.SqlTransaction" /> object to the constructor, an <seecref="T:System.ArgumentException" /> occurs.
69
69
</summary>
70
70
</UseInternalTransaction>
71
+
<CacheMetadata>
72
+
<summary>
73
+
<para>
74
+
When specified, <b>CacheMetadata</b> caches destination table
75
+
metadata after the first bulk copy operation, allowing
76
+
subsequent operations to the same table to skip the metadata
77
+
discovery query. This can improve performance when performing
78
+
multiple bulk copy operations to the same destination table.
79
+
</para>
80
+
<para>
81
+
<b>Warning:</b> Use this option only when you are certain the
82
+
destination table schema will not change between bulk copy
83
+
operations. If the table schema changes (columns added,
84
+
removed, or modified), using cached metadata may result in
85
+
data corruption, failed operations, or unexpected behavior.
// Check if we have valid cached metadata for the current destination table
514
+
if(CachedMetadata!=null)
515
+
{
516
+
SqlClientEventSource.Log.TryTraceEvent("SqlBulkCopy.CreateAndExecuteInitialQueryAsync | Info | Using cached metadata for table '{0}'",_destinationTableName);
517
+
result=CachedMetadata;
518
+
returnnull;
519
+
}
520
+
500
521
stringTDSCommand=CreateInitialQuery();
501
522
SqlClientEventSource.Log.TryTraceEvent("SqlBulkCopy.CreateAndExecuteInitialQueryAsync | Info | Initial Query: '{0}'",TDSCommand);
502
523
SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlBulkCopy.CreateAndExecuteInitialQueryAsync | Info | Correlation | Object Id {0}, Activity Id {1}",ObjectID,ActivityCorrelator.Current);
0 commit comments