6.5. OpenLink.Data Namespace

All the public classes in the OpenLink.Data namespace are detailed in this section. Note that all of the OpenLink .Net Data Providers use the same common class names, thus the descriptions below are applicable to all enabling maximum re-use of code across Providers.

IMPORTANT: Public class members inherited from a base class defined by the .NET Framework Class Library (FCL), or which implement an FCL defined interface method, are not described. For details of these inherited members, refer to the .NET FCL documentation for the base class or interface. Where an OpenLink class implements an ADO.NET interface and adds additional methods or properties, these extensions are documented.

In the class descriptions which follow, all code extracts showing partial class definitions, method signatures etc. are in C#. Examples for other .NET languages are not shown.

6.5.1. OPLCommand

Represents an SQL statement or stored procedure to execute against a database.

public class OPLCommand : Component, IDbCommand, ICloneable

Constructors

public OPLCommand ();

Initializes a new instance of the OPLCommand class.

public OPLCommand (string cmdText);

Initializes a new instance of the OPLCommand class with the text of the query.

public OPLCommand (string cmdText, OPLConnection connection);

Initializes a new instance of the OPLCommand class with the text of the query and an OPLConnection object.

public OPLCommand (string cmdText, OPLConnection connection,OPLTransaction txn);

Initializes a new instance of the OPLCommand class with the text of the query, an OPLConnection object and an OPLTransaction object.

Properties

PassThrough
public bool PassThrough {get; set;}

Allows the command text to be passed to the data source without being parsed by the Generic Provider.

Remarks

The PassThrough property defaults to false. When pass-through is disabled, the Generic Provider parses command text associated with the OPLCommand and queries the data source for additional metadata on tables referenced in a select statement. The command parser in the Generic Provider is limited to the SQL grammar defined by ODBC. If you wish to pass native SQL to the data source you should enable pass-through; however this will have the following side-effects:

Some of the metadata returned by OPLDataReader.GetSchemaTable may not be accurate, specifically the metadata resultset columns IsKeyColumn, BaseSchemaName, BaseCatalogName, BaseTableName.
The command behavior setting CommandBehavior.KeyInfo will not append missing key columns to the end of a select list.
OPLCommandBuilder may not work, depending on the select statement used.

6.5.2. OPLCommandBuilder

Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated data source.

public sealed class OPLCommandBuilder : Component

Constructors

public OPLCommandBuilder ();

Initializes a new instance of the OPLCommandBuilder class.

public OPLCommandBuilder (OPLDataAdapter adapter);

Initializes a new instance of the OPLCommandBuilder class with the associated OPLDataAdapter object.

Methods

public static void DeriveParameters (OPLCommand command);

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

protected override void Dispose (bool disposing);

Releases the resources used by the OPLCommandBuilder.

public OPLCommand GetDeleteCommand ();

Gets the automatically generated OPLCommand object required to perform deletions at the data source.

public OPLCommand GetInsertCommand ();

Gets the automatically generated OPLCommand object required to perform insertions at the data source.

public OPLCommand GetUpdateCommand ();

Gets the automatically generated OPLCommand object required to perform updates at the data source.

public void RefreshSchema ();

Refreshes the database schema information used to generate INSERT, UPDATE, or DELETE statements.

Properties

public OPLDataAdapter DataAdapter {get; set;}

Gets or sets an OPLDataAdapter object for which this OPLCommandBuilder object will generate SQL statements.

public string QuotePrefix {get; set;}

Gets or sets the beginning character or characters to use when working with database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.

public string QuoteSuffix {get; set;}

Gets or sets the ending character or characters to use when working with database objects, (for example, tables or columns), whose names contain characters such as spaces or reserved tokens.

6.5.3. OPLConnect

Represents an open connection to a data source.

public sealed class OPLConnection : Component, ICloneable, IDbConnection

Constructors

public OPLConnection();

Initializes a new instance of the OPLConnect class.

public OPLConnection(string connectionString);

Initializes a new instance of the OPLConnection class with the specified connection string.

Methods

protected override void Dispose (bool disposing);

Releases the resources used by the OPLConnection.

Events

public event StateChangeEventHandler StateChange;

Occurs when the state of the connection changes.

Remarks

The StateChange event is raised immediately after the State changes from Closed to Opened, or from Opened to Closed.

public event OPLInfoMessageEventHandler InfoMessage;

Returns warning messages from the DBMS.

public delegate void OPLInfoMessageEventHandler (object sender, OPLInfoMessageEventArgs e)
class OPLInfoMessageEventArgs;

6.5.4. OPLDataAdapter

Represents a set of data commands and a database connection that are used to fill a DataSet and update a data source.

Constructors

public OPLDataAdapter();

Initializes a new instance of the OPLDataAdapter class.

public OPLDataAdapter (OPLCommand selectCommand);

Initializes a new instance of the OPLDataAdapter class with the specified SQL SELECT statement.

public OPLDataAdapter (string selectCommandText, OPLConnection selectConnection);

Initializes a new instance of the OPLDataAdapter class with an SQL SELECT statement and an OPLConnection.

public OPLDataAdapter (string selectCommandText, string selectConnectionString);

Initializes a new instance of the OPLDataAdapter class with an SQL SELECT statement and a connection string.

Methods

public event OPLRowUpdatedEventHandler RowUpdated;

Occurs during an Update operation after a command is executed against the data source.

public event OPLRowUpdatingEventHandler RowUpdating;

Occurs during an Update operation before a command is executed against the data source.

6.5.5. OPLDataReader

Provides a way of reading a forward-only stream of data rows from a data source.

public sealed class OPLDataReader : MarshalByRefObject, IDataReader, IDataRecord, IDisposable, IEnumerable

6.5.6. OPLError

Holds information about a warning or error returned by a data source.

public sealed class OPLError

Remarks

This class is created whenever an error occurs. Each instance of OPLError created is then managed by the OPLErrorCollection class, which in turn is created by the OPLException class.

Properties

public string Message {get;}

Gets a short description of the error.

public string SQLState {get;}

Gets the five character ODBC SQL state associated with the error.

public int NativeError {get;}

Gets the data source-specific error information.

6.5.7. OPLErrorCollection

Represents a collection of one or more OPLError objects that give detailed information about an OPLException.

public sealed class OPLErrorCollection : ICollection

Remarks

This class is created by OPLException to collect instances of the OPLError class. OPLErrorCollection always contains at least one instance of the OPLError class.

Methods

public IEnumerator GetEnumerator();

This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Properties

public OPLError this[int i] {get;}

Gets the error at the specified index. In C#, this property is the indexer for the OPLErrorCollection class.

6.5.8. OPLException

The exception that is generated when a warning or error is returned by a data source or the Generic Provider.

public sealed class OPLException : SystemException

Properties

public OPLErrorCollection Errors {get;}

Gets a collection of one or more OPLError objects that give detailed information about the exception.

public override string Message {get;}

Gets the text describing the error.

6.5.9. OPLParameter

Represents a parameter to an OPLCommand and optionally, its mapping to a DataSet column.

public class OPLParameter : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable

Constructors

public OPLParameter();

Initializes a new instance of the OPLParameter class.

public OPLParameter(string parameterName, object value);

Initializes a new instance of the OPLParameter class with the parameter name and a value of the new OPLParameter object.

public OPLParameter(string parameterName, OPLDbType type);

Initializes a new instance of the OPLParameter class with the parameter name and the data type.

public OPLParameter(string parameterName, OPLDbType type, int size);

Initializes a new instance of the OPLParameter class with the parameter name, the OPLDbType and the size.

public OPLParameter(string parameterName, OPLDbType type, int size, string sourceColumn);

Initializes a new instance of the OPLParameter class with the parameter name, the OPLDbType, the size, and the source column name.

public OPLParameter(string parameterName, OPLDbType type, int size, ParameterDirection direction, Boolean isNullable, Byte precision, Byte scale, string sourceColumn, DataRowVersion sourceVersion, object value);

Initializes a new instance of the OPLParameter class with the parameter name, the type of the parameter, the size of the parameter, a ParameterDirection, whether the parameter is nullable, the precision of the parameter, the scale of the parameter, the source column, a DataRowVersion to use, and the value of the parameter.

Methods

public override string ToString ();

Gets a string containing the ParameterName.

Properties

public OPLDbType OPLDbType {get; set;}

Gets or sets the OPLDbType of the parameter.

Remarks

The OPLDbType and DbType are linked. Therefore, setting the DbType changes the OPLType to a supporting OPLDbType. For a list of the supported data types, see the appropriate OPLDbType member.

6.5.10. OPLParameterCollection

Represents a collection of parameters relevant to an OPLCommand as well as their respective mappings to columns in a DataSet.

public class OPLParameterCollection : MarshalByRefObject, IDataParameterCollection, ICollection, IEnumerable, IList

Methods

public int Add (OPLParameter value);

Adds the specified OPLParameter to the OPLParameterCollection

public int Add (string parameterName, object value);

Adds an OPLParameter to the OPLParameterCollection given the parameter name and value.

public int Add (string parameterName, OPLDbType dbType);

Adds an OPLParameter to the OPLParameterCollection given the parameter name and data type.

public int Add (string parameterName, OPLDbType dbType, int size);

Adds an OPLParameter to the OPLParameterCollection given the the parameter name, data type, and column length.

public int Add (string parameterName, OPLDbType dbType, int size, string sourceColumn);

Adds an OPLParameter to the OPLParameterCollection given the parameter name, data type, column length, and source column name.

Properties

public OPLParameter this[int index] {get; set;}

Gets or sets the OPLParameter at the specified index

public OPLParameter this[string parameterName] {get; set;}

Gets or sets the OPLParameter with the specified name.

6.5.11. OPLRowUpdatedEventArgs

Provides data for the OPLDataAdapter.RowUpdated event.

Constructors

public OPLRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping);

Initializes a new instance of the OPLRowUpdatedEventArgs class.

properties

public new OPLCommand Command {get;}

Gets the OPLCommand executed when Update is called.

6.5.12. OPLRowUpdatedEventHandler

Represents a method that will handle the RowUpdated event of an OPLDataAdapter.

public delegate void OPLRowUpdatedEventHandler(object sender, OPLRowUpdatedEventArgs e);

6.5.13. OPLRowUpdatingEventArgs

Provides data for the OPLDataAdapter.RowUpdating event.

Constructors

public OPLRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping);

Initializes a new instance of the OPLRowUpdatingEventArgs class.

properties

public new OPLCommand Command {get; set;}

Gets or sets the OPLCommand to execute when Update is called.

6.5.14. OPLRowUpdatingEventHandler

Represents a method that will handle the RowUpdating event of an OPLDataAdapter.

public delegate void OPLRowUpdatingEventHandler(object sender, OPLRowUpdatingEventArgs e);

6.5.15. OPLTransaction

Represents an SQL transaction to be made at a data source.

public sealed class OPLTransaction : MarshalByRefObject, IDbTransaction, IDisposable