Table of Contents

Method ToDataTable

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

ToDataTable(IDbCommand, CommandBehavior)

Executes a reader and loads its first result set into a DataTable.

public static DataTable ToDataTable(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

DataTable

A DataTable that holds the 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.

Exceptions

ArgumentNullException

command is null.