Database Class |
Namespace: NetQuarry
The Database 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 |
This object's ID. Used primarily to load properties for this database
| |
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.
| |
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 |
Returns the object's properties collection
| |
Provider |
Gets/Sets the Provider name to use when creating the encapsulated IDbConnection.
| |
TrackSPID |
Gets/Sets whether the database should track connection SPID's. For Debugging purposes. Use with caution. |
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. | |
Dispose |
Close the database connection(s)
| |
Equals | (Inherited from Object.) | |
Exec |
Execute a DatabaseExecCommands command on the object.
| |
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.
| |
Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
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.
| |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
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.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
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.
| |
LogPerformance |
Logs the duration of an event into the Performance Monitoring System
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
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. | |
ToString | (Inherited from Object.) | |
WakeUp | Wake up (unhibernate) the DB. DB's are hibernated via Hibernate. |
Name | Description | |
---|---|---|
EqualValue |
Determines if the object value is equal to another object. If the two objects are null, then this returns true.
There is special handling for guid comparisons (since a guid could be a string formatted in up to 3 different ways).
If the special guid handling is not performed, then the object.Equals method is used.
(Defined by EAPUtil.) |
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 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(); }