C# Class NSoft.NFramework.Data.OdpNet.EnterpriseLibrary.OdpNetDatabase

Inheritance: Microsoft.Practices.EnterpriseLibrary.Data.Database
显示文件 Open project: debop/NFramework Class Usage Examples

Public Methods

Method Description
AddParameter ( DbCommand command, string name, DbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value ) : void

Adds a new instance of a DbParameter object to the command.

CheckIfOracleCommand ( DbCommand command ) : OracleCommand

Checks if oracle command.

ExecuteDataSet ( DbCommand command ) : DataSet

Executes a command and returns the results in a new DataSet.

ExecuteDataSet ( DbCommand command, DbTransaction transaction ) : DataSet

Executes a command and returns the result in a new DataSet.

ExecuteReader ( DbCommand command ) : IDataReader

Creates an OracleDataReader based on the command.

ExecuteReader ( DbCommand command, DbTransaction transaction ) : IDataReader

Creates an OracleDataReader based on the command.

ExecuteXmlReader ( DbCommand command ) : XmlReader

Executes the OracleCommand and returns a new XmlReader.

Unlike other Execute... methods that take a DbCommand instance, this method does not set the command behavior to close the connection when you close the reader. That means you'll need to close the connection yourself, by calling the command.Connection.Close() method.

There is one exception to the rule above. If you're using TransactionScope to provide implicit transactions, you should NOT close the connection on this reader when you're done. Only close the connection if Transaction.Current is null.

ExecuteXmlReader ( DbCommand command, DbTransaction transaction ) : XmlReader

Executes the OracleCommand in a transaction and returns a new XmlReader.

Unlike other Execute... methods that take a DbCommand instance, this method does not set the command behavior to close the connection when you close the reader. That means you'll need to close the connection yourself, by calling the command.Connection.Close() method.

GetParameterValue ( DbCommand command, string name ) : object

Gets a parameter value.

GetStoredProcCommand ( string storedProcedureName ) : DbCommand

Creates a DbCommand for a stored procedure.

The parameters for the stored procedure will be discovered and the values are assigned in positional order.

LoadDataSet ( DbCommand command, DataSet dataSet, string tableNames ) : void

Loads a DataSet from a DbCommand.

LoadDataSet ( DbCommand command, DataSet dataSet, string tableNames, DbTransaction transaction ) : void

Loads a DataSet from a DbCommand in a transaction.

OdpNetDatabase ( string connectionString ) : System
OdpNetDatabase ( string connectionString, IOraclePackage packages ) : System
SetParameterValue ( DbCommand command, string parameterName, object value ) : void

Sets a parameter value.

Protected Methods

Method Description
DeriveParameters ( DbCommand discoveryCommand ) : void

Retrieves parameter information from the stored procedure specified in the DbCommand and populates the Parameters collection of the specified DbCommand object.

The DbCommand must be an instance of a OracleCommand object.

SameNumberOfParametersAndValues ( DbCommand command, object values ) : bool

Determines if the number of parameters in the command matches the array of parameter values.

SetUpRowUpdatedEvent ( DbDataAdapter adapter ) : void

Sets the RowUpdated event for the data adapter.

The DbDataAdapter must be an OracleDataAdapter.

Private Methods

Method Description
AddInParameter ( DbCommand command, string name, OracleDbType dbType ) : void
AddInParameter ( DbCommand command, string name, OracleDbType dbType, object value ) : void
AddInParameter ( DbCommand command, string name, OracleDbType dbType, string sourceColumn, DataRowVersion sourceVersion ) : void
AddOutParameter ( DbCommand command, string name, OracleDbType dbType, int size ) : void
AddParameter ( DbCommand command, string name, OracleDbType dbType, ParameterDirection direction, string sourceColumn, DataRowVersion sourceVersion, object value ) : void
AddParameter ( DbCommand command, string name, OracleDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value ) : void
ConfigureParameter ( OracleParameter parameter, string name, OracleDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value ) : void
ConvertBoolToShort ( object value ) : object

Converts a Boolean object to a short or DBNull if null.

This is specifically used in the conversion of a Boolean to OracleDbType.Int16. Contrary to most interpretations of a boolean value a value of 0 (zero) stored in a Database is generally regarded as representing false.

ConvertByteArrayToGuid ( object value ) : object

Converts a byte array object to GUID.

This is specifically used in the conversion of OracleDbType.Raw back to Guid

ConvertGuidToByteArray ( object value ) : object

Converts a GUID object to a byte array or DBNull if null.

This is specifically used in the conversion of a Guid to OracleDbType.Raw

ConvertShortToBool ( object value ) : object

Converts a short object to Boolean.

This is specifically used in the conversion of OracleDbType.Int16 back to Boolean

CreateParameter ( string name, OracleDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value ) : DbParameter
DoExecuteXmlReader ( OracleCommand oracleCommand ) : XmlReader

Does the execute XML reader.

Execute the actual XML Reader call.

GetParameterTypeRegistry ( string commandText ) : ParameterTypeRegistry

Gets the parameter type registry for the specified command.

OnOracleRowUpdated ( object sender, OracleRowUpdatedEventArgs args ) : void

Called when a dataset row is updated.

Listens for the RowUpdate event on a data adapter to support UpdateBehavior.Continue

PrepareCWRefCursor ( DbCommand command ) : void

Prepares the CW ref cursor.

This is a private method that will build the Oracle package name if your stored procedure has proper prefix and postfix. This functionality is include for the portability of the architecture between SQL and Oracle datbase. This method also adds the reference cursor to the command writer if not already added. This is required for Oracle .NET managed data provider.

QueryProcedureNeedsCursorParameter ( DbCommand command ) : bool

Queries the procedure to see if it needs a cursor parameter.

RegisterParameterType ( DbCommand command, string parameterName, DbType dbType ) : void

Registers the type of the parameter in a parameter registry.

TranslatePackageSchema ( string storedProcedureName ) : string

Translates the package schema.

Looks into configuration and gets the information on how the command wrapper should be updated if calling a package on this connection.

Method Details

AddParameter() public method

Adds a new instance of a DbParameter object to the command.
public AddParameter ( DbCommand command, string name, DbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value ) : void
command System.Data.Common.DbCommand The command to add the parameter.
name string The name of the parameter.
dbType DbType One of the values.
size int The maximum size of the data within the column.
direction ParameterDirection One of the values.
nullable bool A value indicating whether the parameter accepts (Nothing in Visual Basic) values.
precision byte The maximum number of digits used to represent the .
scale byte The number of decimal places to which is resolved.
sourceColumn string The name of the source column mapped to the DataSet and used for loading or returning the .
sourceVersion DataRowVersion One of the values.
value object The value of the parameter.
return void

CheckIfOracleCommand() public static method

Checks if oracle command.
public static CheckIfOracleCommand ( DbCommand command ) : OracleCommand
command System.Data.Common.DbCommand The command.
return OracleCommand

DeriveParameters() protected method

Retrieves parameter information from the stored procedure specified in the DbCommand and populates the Parameters collection of the specified DbCommand object.
The DbCommand must be an instance of a OracleCommand object.
protected DeriveParameters ( DbCommand discoveryCommand ) : void
discoveryCommand System.Data.Common.DbCommand The to do the discovery.
return void

ExecuteDataSet() public method

Executes a command and returns the results in a new DataSet.
/// can not be (Nothing in Visual Basic). ///
public ExecuteDataSet ( DbCommand command ) : DataSet
command System.Data.Common.DbCommand The command to execute to fill the
return System.Data.DataSet

ExecuteDataSet() public method

Executes a command and returns the result in a new DataSet.
/// can not be (Nothing in Visual Basic). /// /// can not be (Nothing in Visual Basic). /// - or - /// can not be (Nothing in Visual Basic). ///
public ExecuteDataSet ( DbCommand command, DbTransaction transaction ) : DataSet
command System.Data.Common.DbCommand The command to execute to fill the
transaction System.Data.Common.DbTransaction The transaction to participate in when executing this reader.
return System.Data.DataSet

ExecuteReader() public method

Creates an OracleDataReader based on the command.
/// can not be (Nothing in Visual Basic). ///
public ExecuteReader ( DbCommand command ) : IDataReader
command System.Data.Common.DbCommand The command wrapper to execute.
return IDataReader

ExecuteReader() public method

Creates an OracleDataReader based on the command.
/// can not be (Nothing in Visual Basic). /// - or - /// can not be (Nothing in Visual Basic). ///
public ExecuteReader ( DbCommand command, DbTransaction transaction ) : IDataReader
command System.Data.Common.DbCommand The command wrapper to execute.
transaction System.Data.Common.DbTransaction The transaction to participate in when executing this reader.
return IDataReader

ExecuteXmlReader() public method

Executes the OracleCommand and returns a new XmlReader.
Unlike other Execute... methods that take a DbCommand instance, this method does not set the command behavior to close the connection when you close the reader. That means you'll need to close the connection yourself, by calling the command.Connection.Close() method.

There is one exception to the rule above. If you're using TransactionScope to provide implicit transactions, you should NOT close the connection on this reader when you're done. Only close the connection if Transaction.Current is null.

public ExecuteXmlReader ( DbCommand command ) : XmlReader
command System.Data.Common.DbCommand The to execute.
return System.Xml.XmlReader

ExecuteXmlReader() public method

Executes the OracleCommand in a transaction and returns a new XmlReader.
Unlike other Execute... methods that take a DbCommand instance, this method does not set the command behavior to close the connection when you close the reader. That means you'll need to close the connection yourself, by calling the command.Connection.Close() method.
public ExecuteXmlReader ( DbCommand command, DbTransaction transaction ) : XmlReader
command System.Data.Common.DbCommand The to execute.
transaction System.Data.Common.DbTransaction The to execute the command within.
return System.Xml.XmlReader

GetParameterValue() public method

Gets a parameter value.
public GetParameterValue ( DbCommand command, string name ) : object
command System.Data.Common.DbCommand The command that contains the parameter.
name string The name of the parameter.
return object

GetStoredProcCommand() public method

Creates a DbCommand for a stored procedure.
The parameters for the stored procedure will be discovered and the values are assigned in positional order.
public GetStoredProcCommand ( string storedProcedureName ) : DbCommand
storedProcedureName string The name of the stored procedure.
return System.Data.Common.DbCommand

LoadDataSet() public method

Loads a DataSet from a DbCommand.
public LoadDataSet ( DbCommand command, DataSet dataSet, string tableNames ) : void
command System.Data.Common.DbCommand The command to execute to fill the .
dataSet System.Data.DataSet The to fill.
tableNames string An array of table name mappings for the .
return void

LoadDataSet() public method

Loads a DataSet from a DbCommand in a transaction.
public LoadDataSet ( DbCommand command, DataSet dataSet, string tableNames, DbTransaction transaction ) : void
command System.Data.Common.DbCommand The command to execute to fill the .
dataSet System.Data.DataSet The to fill.
tableNames string An array of table name mappings for the .
transaction System.Data.Common.DbTransaction The to execute the command in.
return void

OdpNetDatabase() public method

public OdpNetDatabase ( string connectionString ) : System
connectionString string
return System

OdpNetDatabase() public method

public OdpNetDatabase ( string connectionString, IOraclePackage packages ) : System
connectionString string
packages IOraclePackage
return System

SameNumberOfParametersAndValues() protected method

Determines if the number of parameters in the command matches the array of parameter values.
protected SameNumberOfParametersAndValues ( DbCommand command, object values ) : bool
command System.Data.Common.DbCommand The containing the parameters.
values object The array of parameter values.
return bool

SetParameterValue() public method

Sets a parameter value.
public SetParameterValue ( DbCommand command, string parameterName, object value ) : void
command System.Data.Common.DbCommand The command with the parameter.
parameterName string The parameter name.
value object The parameter value.
return void

SetUpRowUpdatedEvent() protected method

Sets the RowUpdated event for the data adapter.
The DbDataAdapter must be an OracleDataAdapter.
protected SetUpRowUpdatedEvent ( DbDataAdapter adapter ) : void
adapter System.Data.Common.DbDataAdapter The to set the event.
return void