IDatabase Interface |
Namespace: NetQuarry
The IDatabase type exposes the following members.
Name | Description | |
---|---|---|
Application |
Returns the connected IAppContext object.
| |
Attributes |
Gets/Sets the Database DatabaseAttrs attributes.
| |
CanLogPerformance |
Gets/Sets whether the database can begin to log performance requests.
If an application is set (via Logging Feature) to utilize a Diagnostic Service,
we can't begin logging database requests until the application has completed loading Feature collections.
Otherwise the request for features causes a recursion in the database code.
| |
CommandTimeout |
Gets/Sets the CommandTimeout value.
| |
Connection |
Gets the string used to open the encapsulated IDbConnection.
| |
ConnectionString |
Gets/Sets the connection string of the enclosed IDbConnection object.
| |
DatabaseID |
Gets/Sets the database ID.
| |
DatabaseName |
Gets the name of the database associated with this object.
| |
DBMSType |
Returns the DBMSType of the currently connected database.
| |
DBMSVersionMajor |
Gets the DBMS major version number or zero if no version can be determined.
Use DBMSVersionMinor to get the minor version number.
| |
DBMSVersionMinor |
Gets the DBMS minor version number.
Note that the minor version number is valid only if DBMSVersionMajor, the
major version number, is positive.
Use DBMSVersionMajor to get the major version number.
| |
ID |
Gets the object's unique identifier.
(Inherited from IEAPBase.) | |
IsOpen |
Returns True if the underlying connection is open
| |
LogDBExecutionCacheHits |
Gets/Sets whether the database should log (to devlog) cache hits/misses on DBExecutions (DBLookup, DBExists, DBCount) within same thread context. For Debugging purposes. Use with caution. | |
LogDuplicateDBExecutions |
Gets/Sets whether the database should log (to devlog) duplicate requests for DB Executions (DBLookup, DBExists, DBCount) within same thread context. For Debugging purposes. Use with caution. | |
Properties |
The Properties collection of Property objects for this object.
(Inherited from IEAPBase.) | |
Provider |
Gets/Sets the Provider name to use when creating the encapsulated IDbConnection.
| |
TextItems | (Inherited from IEAPBase.) | |
TrackSPID |
Gets/Sets whether the database should track connection SPID's. For Debugging purposes. Use with caution. | |
Version |
Gets/sets the version of this object's assembly.
(Inherited from IEAPBase.) |
Name | Description | |
---|---|---|
BeginTransaction |
Starts a database transaction.
Call CommitTransaction to commit a transaction.
Call RollbackTransaction to roll back a transaction.
| |
Clone |
Make a clone of the current database.
| |
Close |
The Close method closes the underlying Connection object and rolls back any pending transactions.
It then releases the connection to the connection pool, or closes the connection if connection pooling
is disabled.
| |
CommitTransaction |
Commits a database transaction.
Call BeginTransaction to begin a transaction.
Call RollbackTransaction to roll back a transaction.
| |
DBCount(String, String, String) |
Returns the number of items in the specified column and table using the SQL WHERE clause supplied.
Note: For improved performance use DBExists(String, String) when possible. | |
DBCount(String, String, String, DataFuncOptions, String) |
Returns the number of items in the specified column and table using the SQL WHERE clause supplied.
Note: For improved performance use DBExists(String, String, DataFuncOptions, String) when possible. | |
DBCount(String, String, String, DataFuncOptions, String, Int32) |
Returns the number of items in the specified column and table using the SQL WHERE clause supplied.
Note: For improved performance use DBExists(String, String, DataFuncOptions, String) when possible. | |
DBCountCache |
Returns the number of items in the specified column and table using the SQL WHERE clause supplied.
Note: For improved performance use DBExistsCache(String, String, DataFuncOptions, String) when possible.
DBCountCache is an enhancement to the existing DBCount function. Ultimately we still use the same DBCount mechanism to retrieve the required value
but the result is cached to Thread Local Storage. Subsequent requests to lookup the same count (using the SAME SQL) will pull that value from the thread cache
rather than hitting the database. | |
DBExists(String, String) |
Determines if a particular record exists.
For better performance and clarity, use this instead of DBCount(String, String, String) to
determine if a record or records exist.
| |
DBExists(String, String, DataFuncOptions) |
Determines if a particular record exists.
For better performance and clarity, use this instead of DBCount(String, String, String, DataFuncOptions, String) to
determine if a record or records exist.
| |
DBExists(String, String, DataFuncOptions, String) |
Determines if a particular record exists.
For better performance and clarity, use this instead of DBCount(String, String, String, DataFuncOptions, String) to
determine if a record or records exist.
| |
DBExistsCache |
Determines if a particular record exists.
For better performance and clarity, use this instead of DBCount(String, String, String, DataFuncOptions, String) to
determine if a record or records exist.
DBExistsCache is an enhancement to the existing DBExists function. Ultimately we still use the same DBExists mechanism to retrieve the required value
but the result is cached to Thread Local Storage. Subsequent requests to check existence of the same value (using the SAME SQL) will pull that value from the thread cache
rather than hitting the database.
| |
DBLookup(String, String, String) |
You can use the DBLookup function to get the value of a particular column from a specified set of records
(a domain). | |
DBLookup(String, String, String, DataFuncOptions, String) |
You can use the DBLookup function to get the value of a particular column from a specified set of records
(a domain). | |
DBLookup(String, String, String, DataFuncOptions, String, String) |
You can use the DBLookup function to get the value of a particular column from a specified set of records
(a domain). | |
DBLookupCache |
DBLookupCache is an enhancement to the existing DBLookup function. Ultimately we still use the same DBLookup mechanism to retrieve the required value
but the result is cached to Thread Local Storage. Subsequent requests to lookup the same value (using the SAME SQL) will pull that value from the thread cache
rather than hitting the database. | |
Exec |
The Exec method provides extended functionality.
(Inherited from IEAPBase.) | |
Execute(String) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, String) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, ExecuteOptions, String) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, String, Int32) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, ExecuteOptions, String, String) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, ExecuteOptions, String, String, Int32) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, ExecuteOptions, String, String, String) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, ExecuteOptions, String, String, String, Int32) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
Execute(String, ExecuteOptions, String, String, String, Int32, Int32) |
You can use the Execute method to perform catalog operations (for example, creating database objects such as tables),
or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. | |
ExecuteScalar(String, String) |
Execute a scalar SQL statement (a statement that returns a single item).
| |
ExecuteScalar(String, String, Int32) |
Execute a scalar SQL statement (a statement that returns a single item).
| |
ExecuteThroughAdapter(String, String, Hashtable, ExecuteThroughAdapterAttrs) |
Executes an insert, update or delete through IDbDataAdapter, Dataset, DataTable, DataRow
| |
ExecuteThroughAdapter(String, String, Hashtable, ExecuteThroughAdapterAttrs, String) |
Executes an insert, update or delete through IDbDataAdapter, Dataset, DataTable, DataRow
| |
FillStringCollection |
Fill a StringCollection with the contents of the first column in the provided query.
Note that each value will be converted to a string.
| |
FireAndForget(String, ExecuteOptions, String) |
Execute the specified SQL asynchronously. The SQL execution is spun off to the thread pool to be executed when
a thread becomes available, and control is returned to the caller immediately.
Note that there is no way to get the result, or success/failure of the execution except to query if from the database.
| |
FireAndForget(String, ExecuteOptions, String, FireAndForgetOptions) |
Execute the specified SQL asynchronously. The SQL execution is spun off to the thread pool to be executed when
a thread becomes available, and control is returned to the caller immediately.
Note that there is no way to get the result, or success/failure of the execution except to query if from the database.
| |
GetSchemaInfo(String) |
Gets a SchemaInfoCollection describing the specified table or view with SchemaInfo objects for each column.
Note that schema information is cached on demand and per-DatabaseID.
If the specified table does not exist then an empty (but not null) SchemaInfoCollection will be returned and
you can test ObjectExists to determine whether or not the object exists.
You can use GetSchemaInfo(String, SchemaInfoType) for various schema object, including tables and views.
| |
GetSchemaInfo(String, SchemaInfoType) |
Gets a SchemaInfoCollection describing the specified database object with SchemaInfo objects for each column or input parameter.
Note that schema information is cached on demand and per-DatabaseID.
If the specified table does not exist then an empty (but not null) SchemaInfoCollection will be returned and
you can test ObjectExists to determine whether or not the object exists.
| |
Hibernate | Hibernate the DB. Hibernated DB's are awoken via WakeUp. | |
LoadFile |
Load the specified file data into a memory stream.
If no records are found then the stream object will be created, but will be empty.
If multiple records are found then data will be loaded from the first record only.
| |
LoadProperties |
Loads the database Properties from the repository database.
| |
Open |
Opens the connection to the underlying data source.
| |
Open(IAppContext, String) |
Opens the connection to the underlying data source.
| |
Open(IAppContext, String, DatabaseOpenOptions) |
Opens the connection to the underlying data source.
| |
OpenCachedTable(String, String) |
Opens a new DataSet and returns the first DataTable, retrieving it from the cache
if it is cached. If the object is not cached, it is opened from the datasource and
added to the global cache.
| |
OpenCachedTable(String, String, String) |
Opens a new DataSet and returns the first DataTable, retrieving it from the cache
if it is cached. If the object is not cached, it is opened from the datasource and
added to the global cache.
| |
OpenCachedTable(String, String, String, Boolean) |
Opens a new DataSet and returns the first DataTable, retrieving it from the cache
if it is cached. If the object is not cached, it is opened from the datasource and
added to the global cache.
| |
OpenDataReader(String) |
Opens a recordset using the internal connection and default options.
| |
OpenDataReader(String, String) |
Opens a recordset using the internal connection and default options.
| |
OpenDataReader(String, DataFuncOptions, String) |
Opens a recordset using the internal connection.
| |
OpenDataReader(String, String, Int32) |
Opens a recordset using the internal connection.
| |
OpenDataReader(String, IDbConnection, DataFuncOptions, String) |
Opens a recordset using the specified connection.
| |
OpenDataReader(String, IDbConnection, DataFuncOptions, String, String) |
Opens a recordset using the specified connection.
| |
OpenDataReader(String, IDbConnection, DataFuncOptions, String, String, Int32) |
Opens a recordset using the specified connection.
| |
OpenDataset(String) | Opens one or more tables or views. | |
OpenDataset(String, String) | Opens one or more tables or views. | |
OpenDataset(String, String, Int32) | Opens one or more tables or views. | |
OpenHashtable |
Opens a 2 column statement on the encapsulated connection and returns the results as a hashtable.
Note that a hashtable is ALWAYS returned even if no records were found (in which case it will be empty).
| |
OpenTable(String) |
Opens a new DataSet and returns the first DataTable.
If caching is appropriate use OpenCachedTable(String, String) for improved performace.
| |
OpenTable(String, String) |
Opens a new DataSet and returns the first DataTable.
If caching is appropriate use OpenCachedTable(String, String, String) for improved performace.
| |
OpenTable(String, String, Int32) |
Opens a new DataSet and returns the first DataTable.
If caching is appropriate use OpenCachedTable(String, String, String) for improved performace.
| |
ResolveEmbeddedFunction |
Resolve a SQL string for embedded functions.
See EmbeddedParser for more information on embedded functions.
| |
RollbackTransaction |
Rolls back a database transaction.
Call BeginTransaction to begin a transaction.
Call CommitTransaction to commit a transaction.
| |
TableSpace |
Gets the space used by the specified table.
Currently this method is only supported for SQL-Server where the
sp_spaceused stored procedure is used.
For non-supported DBMS's, an empty (non-null) space descriptor is returned.
At this time, an exception is thrown if the table does not exist, but this behaviour may change in the future and is not guaranteed. | |
WakeUp | Wake up (unhibernate) the DB. DB's are hibernated via Hibernate. |
Application extensions can use this class in a variety of situations, such as reading data for display, passing data through application layers, and submitting changed data back to the database system. The class includes support for both stored procedures and in-line SQL.
Common housekeeping tasks, such as managing connections, are encapsulated in the class' methods. In other words, the Database class provides access to the most often used features of ADO.NET in simple-to-use classes; this boosts developer productivity.
ADO.NET 2.0 provides classes such as the DbCommand class and the DbConnection class; these classes help to abstract the data provider from any particular database implementation. The Database class takes advantage of these classes and provides a model that further supports encapsulation of database type-specific features, such as type conversions. Because of this, applications can be ported from one database type to another without modifying the client code.
The Database class includes an abstract base class that defines a common interface and that provides much of the implementation needed by the data access methods available in ADO.NET 2.0.
The Database class provides the following benefits:
IDatabase provides a set of lookup-like utility functions, each with several overloads:
IDatabase provides a set of generalized database query functions, each with several overloads:
IDatabase supports infrequently used, extended functionality via calls to Exec(DatabaseExecCommands, Int32, Object) with a DatabaseExecCommands value.
The following helper classes may be useful when rolling your own statements:
IDatabase db = appContext.Databases["Studio"]; System.Collections.Generic.Dictionary<string, string> props = new System.Collections.Generic.Dictionary<string, string>(); IDataReader dr = null; try { using (dr = db.OpenDataReader("SELECT prop_id, prop_value FROM xmt_properties WHERE prop_value is not null")) { while (dr.Read()) { props.Add(dr.GetString(0), dr.GetString(1)); } dr.Close(); } dr = null; } catch (Exception ex) { DevLog.LogMessage("OpenProperties", "dataReadError", ex); throw; } finally { if (dr != null) dr.Close(); }
IDatabase db = new Database(); db.DatabaseID = "main"; db.OpenDatabase("Provider=SQLOLEDB;Data Source=.;Initial Catalog=my_database", "myuser", "mypassword", 0); DataSet ds = db.OpenDataset("SELECT * FROM customer");