@@ -30,6 +30,20 @@ public abstract class BulkCopy : IDisposable
30
30
return DynamicBulkCopy . Create ( obj ) ;
31
31
}
32
32
33
+ /// <summary>
34
+ /// Create a BulkCopy instance for the connection provided
35
+ /// </summary>
36
+ public static BulkCopy Create ( DbConnection connection )
37
+ {
38
+ var bcp = TryCreate ( connection ) ;
39
+ if ( bcp == null )
40
+ {
41
+ if ( connection == null ) throw new ArgumentNullException ( nameof ( connection ) ) ;
42
+ throw new NotSupportedException ( "Unable to create BulkCopy for " + connection . GetType ( ) . FullName ) ;
43
+ }
44
+ return bcp ;
45
+ }
46
+
33
47
/// <summary>
34
48
/// Provide an external registration for a given connection type
35
49
/// </summary>
@@ -74,15 +88,23 @@ private static readonly ConcurrentDictionary<Type, Func<DbConnection, object>?>
74
88
/// <summary>
75
89
/// Write a set of data to the server
76
90
/// </summary>
91
+ public abstract void WriteToServer ( DataRow [ ] source ) ;
92
+ /// <summary>
93
+ /// Write a set of data to the server
94
+ /// </summary>
77
95
public abstract void WriteToServer ( IDataReader source ) ;
78
96
/// <summary>
79
97
/// Write a set of data to the server
80
98
/// </summary>
81
- public abstract Task WriteToServerAsync ( DbDataReader source , CancellationToken cancellationToken ) ;
99
+ public abstract Task WriteToServerAsync ( DbDataReader source , CancellationToken cancellationToken = default ) ;
100
+ /// <summary>
101
+ /// Write a set of data to the server
102
+ /// </summary>
103
+ public abstract Task WriteToServerAsync ( DataTable source , CancellationToken cancellationToken = default ) ;
82
104
/// <summary>
83
105
/// Write a set of data to the server
84
106
/// </summary>
85
- public abstract Task WriteToServerAsync ( DataTable source , CancellationToken cancellationToken ) ;
107
+ public abstract Task WriteToServerAsync ( DataRow [ ] source , CancellationToken cancellationToken = default ) ;
86
108
/// <summary>
87
109
/// Add a mapping between two columns by name
88
110
/// </summary>
0 commit comments