Table of Contents

Method ToDataTables

Namespace
Open.Database.Extensions.Synchronous
Assembly
Open.Database.Extensions.Core.dll

ToDataTables(IDbCommand, CommandBehavior)

Executes a reader and loads each result set into its own DataTable.

public static List<DataTable> ToDataTables(this IDbCommand command, CommandBehavior behavior = CommandBehavior.SequentialAccess)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader. The default is SequentialAccess.

Returns

List<DataTable>

A list of tables, one for each result set.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

It calls NextResult() to check for more results.

Exceptions

ArgumentNullException

command is null.