@@ -143,21 +143,166 @@ public virtual void EnlistTransaction(System.Transactions.Transaction? transacti
143
143
144
144
// these need to be here so that GetSchema is visible when programming to a dbConnection object.
145
145
// they are overridden by the real implementations in DbConnectionBase
146
+
147
+ /// <summary>
148
+ /// Returns schema information for the data source of this <see cref="DbConnection" />.
149
+ /// </summary>
150
+ /// <returns>A <see cref="DataTable" /> that contains schema information.</returns>
151
+ /// <remarks>
152
+ /// If the connection is associated with a transaction, executing <see cref="GetSchema()" /> calls may cause
153
+ /// some providers to throw an exception.
154
+ /// </remarks>
146
155
public virtual DataTable GetSchema ( )
147
156
{
148
157
throw ADP . NotSupported ( ) ;
149
158
}
150
159
160
+ /// <summary>
161
+ /// Returns schema information for the data source of this <see cref="DbConnection" /> using the specified
162
+ /// string for the schema name.
163
+ /// </summary>
164
+ /// <param name="collectionName">Specifies the name of the schema to return.</param>
165
+ /// <returns>A <see cref="DataTable" /> that contains schema information.</returns>
166
+ /// <exception cref="ArgumentException">
167
+ /// <paramref name="collectionName" /> is specified as <see langword="null" />.
168
+ /// </exception>
169
+ /// <remarks>
170
+ /// If the connection is associated with a transaction, executing <see cref="GetSchema(string)" /> calls may cause
171
+ /// some providers to throw an exception.
172
+ /// </remarks>
151
173
public virtual DataTable GetSchema ( string collectionName )
152
174
{
153
175
throw ADP . NotSupported ( ) ;
154
176
}
155
177
178
+ /// <summary>
179
+ /// Returns schema information for the data source of this <see cref="DbConnection" /> using the specified
180
+ /// string for the schema name and the specified string array for the restriction values.
181
+ /// </summary>
182
+ /// <param name="collectionName">Specifies the name of the schema to return.</param>
183
+ /// <param name="restrictionValues">Specifies a set of restriction values for the requested schema.</param>
184
+ /// <returns>A <see cref="DataTable" /> that contains schema information.</returns>
185
+ /// <exception cref="ArgumentException">
186
+ /// <paramref name="collectionName" /> is specified as <see langword="null" />.
187
+ /// </exception>
188
+ /// <remarks>
189
+ /// <para>
190
+ /// The <paramref name="restrictionValues" /> parameter can supply n depth of values, which are specified by the
191
+ /// restrictions collection for a specific collection. In order to set values on a given restriction, and not
192
+ /// set the values of other restrictions, you need to set the preceding restrictions to null and then put the
193
+ /// appropriate value in for the restriction that you would like to specify a value for.
194
+ /// </para>
195
+ /// <para>
196
+ /// An example of this is the "Tables" collection. If the "Tables" collection has three restrictions (database,
197
+ /// owner, and table name) and you want to get back only the tables associated with the owner "Carl", you must
198
+ /// pass in the following values at least: null, "Carl". If a restriction value is not passed in, the default
199
+ /// values are used for that restriction. This is the same mapping as passing in null, which is different from
200
+ /// passing in an empty string for the parameter value. In that case, the empty string ("") is considered to be
201
+ /// the value for the specified parameter.
202
+ /// </para>
203
+ /// <para>
204
+ /// If the connection is associated with a transaction, executing <see cref="GetSchema(string, string[])" />
205
+ /// calls may cause some providers to throw an exception.
206
+ /// </para>
207
+ /// </remarks>
156
208
public virtual DataTable GetSchema ( string collectionName , string ? [ ] restrictionValues )
157
209
{
158
210
throw ADP . NotSupported ( ) ;
159
211
}
160
212
213
+ /// <summary>
214
+ /// This is the asynchronous version of <see cref="GetSchema()" />.
215
+ /// Providers should override with an appropriate implementation.
216
+ /// The cancellation token can optionally be honored.
217
+ /// The default implementation invokes the synchronous <see cref="GetSchema()" /> call and returns a completed
218
+ /// task.
219
+ /// The default implementation will return a cancelled task if passed an already cancelled cancellationToken.
220
+ /// Exceptions thrown by <see cref="GetSchema()" /> will be communicated via the returned Task Exception
221
+ /// property.
222
+ /// </summary>
223
+ /// <param name="cancellationToken">The cancellation instruction.</param>
224
+ /// <returns>A task representing the asynchronous operation.</returns>
225
+ public virtual Task < DataTable > GetSchemaAsync ( CancellationToken cancellationToken = default )
226
+ {
227
+ if ( cancellationToken . IsCancellationRequested )
228
+ {
229
+ return Task . FromCanceled < DataTable > ( cancellationToken ) ;
230
+ }
231
+
232
+ try
233
+ {
234
+ return Task . FromResult ( GetSchema ( ) ) ;
235
+ }
236
+ catch ( Exception e )
237
+ {
238
+ return Task . FromException < DataTable > ( e ) ;
239
+ }
240
+ }
241
+
242
+ /// <summary>
243
+ /// This is the asynchronous version of <see cref="GetSchema(string)" />.
244
+ /// Providers should override with an appropriate implementation.
245
+ /// The cancellation token can optionally be honored.
246
+ /// The default implementation invokes the synchronous <see cref="GetSchema(string)" /> call and returns a
247
+ /// completed task.
248
+ /// The default implementation will return a cancelled task if passed an already cancelled cancellationToken.
249
+ /// Exceptions thrown by <see cref="GetSchema(string)" /> will be communicated via the returned Task Exception
250
+ /// property.
251
+ /// </summary>
252
+ /// <param name="collectionName">Specifies the name of the schema to return.</param>
253
+ /// <param name="cancellationToken">The cancellation instruction.</param>
254
+ /// <returns>A task representing the asynchronous operation.</returns>
255
+ public virtual Task < DataTable > GetSchemaAsync (
256
+ string collectionName ,
257
+ CancellationToken cancellationToken = default )
258
+ {
259
+ if ( cancellationToken . IsCancellationRequested )
260
+ {
261
+ return Task . FromCanceled < DataTable > ( cancellationToken ) ;
262
+ }
263
+
264
+ try
265
+ {
266
+ return Task . FromResult ( GetSchema ( collectionName ) ) ;
267
+ }
268
+ catch ( Exception e )
269
+ {
270
+ return Task . FromException < DataTable > ( e ) ;
271
+ }
272
+ }
273
+
274
+ /// <summary>
275
+ /// This is the asynchronous version of <see cref="GetSchema(string, string[])" />.
276
+ /// Providers should override with an appropriate implementation.
277
+ /// The cancellation token can optionally be honored.
278
+ /// The default implementation invokes the synchronous <see cref="GetSchema(string, string[])" /> call and
279
+ /// returns a completed task.
280
+ /// The default implementation will return a cancelled task if passed an already cancelled cancellationToken.
281
+ /// Exceptions thrown by <see cref="GetSchema(string, string[])" /> will be communicated via the returned Task
282
+ /// Exception property.
283
+ /// </summary>
284
+ /// <param name="collectionName">Specifies the name of the schema to return.</param>
285
+ /// <param name="restrictionValues">Specifies a set of restriction values for the requested schema.</param>
286
+ /// <param name="cancellationToken">The cancellation instruction.</param>
287
+ /// <returns>A task representing the asynchronous operation.</returns>
288
+ public virtual Task < DataTable > GetSchemaAsync ( string collectionName , string ? [ ] restrictionValues ,
289
+ CancellationToken cancellationToken = default )
290
+ {
291
+ if ( cancellationToken . IsCancellationRequested )
292
+ {
293
+ return Task . FromCanceled < DataTable > ( cancellationToken ) ;
294
+ }
295
+
296
+ try
297
+ {
298
+ return Task . FromResult ( GetSchema ( collectionName , restrictionValues ) ) ;
299
+ }
300
+ catch ( Exception e )
301
+ {
302
+ return Task . FromException < DataTable > ( e ) ;
303
+ }
304
+ }
305
+
161
306
protected virtual void OnStateChange ( StateChangeEventArgs stateChange )
162
307
{
163
308
if ( _suppressStateChangeForReconnection )
0 commit comments