C# Class OBeautifulCode.Database.Recipes.DatabaseHelper

ファイルを表示 Open project: NaosProject/Naos.SqlServer

Public Methods

Method Description
ExecuteReader ( SqlConnection connection, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, SqlTransaction transaction = null, CommandBehavior commandBehavior = CommandBehavior.Default, bool prepareCommand = false ) : SqlDataReader

Executes the commandText against the connection and builds an SqlDataReader.

If an expected parameter type does not match an actual parameter value's type, ExecuteReader() does not throw SqlException. Instead, a reader with no rows is returned. Any attempt to Read() will throw an exception.

ExecuteReaderAsync ( SqlConnection connection, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, SqlTransaction transaction = null, CommandBehavior commandBehavior = CommandBehavior.Default, bool prepareCommand = false ) : Task

Executes the commandText against the connection and builds an SqlDataReader.

If an expected parameter type does not match an actual parameter value's type, ExecuteReader() does not throw SqlException. Instead, a reader with no rows is returned. Any attempt to Read() will throw an exception.

ExecuteReaderAsync ( string connectionString, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, CommandBehavior commandBehavior = CommandBehavior.CloseConnection, bool prepareCommand = false, SqlInfoMessageEventHandler sqlInfoMessageEventHandler = null ) : Task

Opens a connection to the database, executes the commandText, and builds an SqlDataReader.

If an expected parameter type does not match an actual parameter value's type, ExecuteReader() does not throw SqlException. Instead, a reader with no rows is returned. Any attempt to Read() will throw an exception.

Private Methods

Method Description
ExecuteReader ( string connectionString, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, CommandBehavior commandBehavior = CommandBehavior.CloseConnection, bool prepareCommand = false, SqlInfoMessageEventHandler sqlInfoMessageEventHandler = null ) : SqlDataReader

Method Details

ExecuteReader() public static method

Executes the commandText against the connection and builds an SqlDataReader.
If an expected parameter type does not match an actual parameter value's type, ExecuteReader() does not throw SqlException. Instead, a reader with no rows is returned. Any attempt to Read() will throw an exception.
public static ExecuteReader ( SqlConnection connection, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, SqlTransaction transaction = null, CommandBehavior commandBehavior = CommandBehavior.Default, bool prepareCommand = false ) : SqlDataReader
connection SqlConnection An open connection to the database.
commandText string The SQL statement, table name, or stored procedure to execute at the data source.
commandTimeoutInSeconds int OPTIONAL value with the wait time, in seconds, before terminating an attempt to execute the command and generating an error. DEFAULT is 30 seconds. A value of 0 indicates no limit (an attempt to execute a command will wait indefinitely).
commandParameters IReadOnlyList OPTIONAL set of parameters to associate with the command. DEFAULT is null (no parameters).
commandType CommandType OPTIONAL value that determines how the command text is to be interpreted. DEFAULT is ; a SQL text command.
transaction SqlTransaction OPTIONAL transaction within which the command will execute. DEFAULT is null (no transaction).
commandBehavior CommandBehavior OPTIONAL value providing a description of the results of the query and its effect on the database. DEFAULT is ; the query may return multiple result sets and execution of the query may affect the database state. This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
prepareCommand bool OPTIONAL value indicating whether to prepared (or compile) the command on the data source.
return SqlDataReader

ExecuteReaderAsync() public static method

Executes the commandText against the connection and builds an SqlDataReader.
If an expected parameter type does not match an actual parameter value's type, ExecuteReader() does not throw SqlException. Instead, a reader with no rows is returned. Any attempt to Read() will throw an exception.
public static ExecuteReaderAsync ( SqlConnection connection, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, SqlTransaction transaction = null, CommandBehavior commandBehavior = CommandBehavior.Default, bool prepareCommand = false ) : Task
connection SqlConnection An open connection to the database.
commandText string The SQL statement, table name, or stored procedure to execute at the data source.
commandTimeoutInSeconds int OPTIONAL value with the wait time, in seconds, before terminating an attempt to execute the command and generating an error. DEFAULT is 30 seconds. A value of 0 indicates no limit (an attempt to execute a command will wait indefinitely).
commandParameters IReadOnlyList OPTIONAL set of parameters to associate with the command. DEFAULT is null (no parameters).
commandType CommandType OPTIONAL value that determines how the command text is to be interpreted. DEFAULT is ; a SQL text command.
transaction SqlTransaction OPTIONAL transaction within which the command will execute. DEFAULT is null (no transaction).
commandBehavior CommandBehavior OPTIONAL value providing a description of the results of the query and its effect on the database. DEFAULT is ; the query may return multiple result sets and execution of the query may affect the database state. This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
prepareCommand bool OPTIONAL value indicating whether to prepared (or compile) the command on the data source.
return Task

ExecuteReaderAsync() public static method

Opens a connection to the database, executes the commandText, and builds an SqlDataReader.
If an expected parameter type does not match an actual parameter value's type, ExecuteReader() does not throw SqlException. Instead, a reader with no rows is returned. Any attempt to Read() will throw an exception.
public static ExecuteReaderAsync ( string connectionString, string commandText, int commandTimeoutInSeconds = 30, IReadOnlyList commandParameters = null, CommandType commandType = CommandType.Text, CommandBehavior commandBehavior = CommandBehavior.CloseConnection, bool prepareCommand = false, SqlInfoMessageEventHandler sqlInfoMessageEventHandler = null ) : Task
connectionString string String used to open a connection to the database.
commandText string The SQL statement, table name, or stored procedure to execute at the data source.
commandTimeoutInSeconds int OPTIONAL value with the wait time, in seconds, before terminating an attempt to execute the command and generating an error. DEFAULT is 30 seconds. A value of 0 indicates no limit (an attempt to execute a command will wait indefinitely).
commandParameters IReadOnlyList OPTIONAL set of parameters to associate with the command. DEFAULT is null (no parameters).
commandType CommandType OPTIONAL value that determines how the command text is to be interpreted. DEFAULT is ; a SQL text command.
commandBehavior CommandBehavior OPTIONAL value providing a description of the results of the query and its effect on the database. DEFAULT is ; the query may return multiple result sets and execution of the query may affect the database state. This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
prepareCommand bool OPTIONAL value indicating whether to prepared (or compile) the command on the data source.
sqlInfoMessageEventHandler SqlInfoMessageEventHandler OPTIONAL method that will handle the event.
return Task