IDBContext
Provides a mockable interface with many common helper methods to interact with a database in a Relativity instance.
While the Services API should be used to interact with Relativity, the implementation of this interface can be used
to interact with the database directly when appropriate.
Gets a database name.
Checks if database is Master context
Gets a database server name.
void BeginTransaction()
Starts a database transaction.
Asynchronously opens a transaction against the connected SQL server.
void Cancel()
Tries to cancel a SQL command execution.
void CommitTransaction()
Commits a database transaction.
Returns a database Parameter
Task ExecuteBulkCopyAsync(IDataReader source, ISqlBulkCopyParameters parameters, CancellationToken cancelToken)
Copies data from the provided IDataReader using the provided ISqlBulkCopyParameters bulk copy parameters.
Asynchronously executes a call to SQL and collects the results into a DataTable.
Task<IEnumerable<T>> ExecuteEnumerableAsync<T>(IQuery query, Func<IDataRecord, CancellationToken, Task<T>> converter)
Asynchronously executes a call to SQL and passes the supplied converter over each of the
resulting data records, coalescing that output into an IEnumerable<T>.
Asychronously executes a call to SQL
Executes a Transact-SQL statement against the connection and returns the number of rows affected.
Executes a Transact-SQL statement against the connection and returns the number of rows affected.
Executes a parameterized Transact-SQL statement against the connection and returns the number of rows affected.
int ExecuteNonQuerySQLStatement(string sqlStatement, IEnumerable<SqlParameter> parameters, int timeoutValue)
Executes a Transact-SQL statement against the connection and returns the number of rows affected.
Task<T> ExecuteObjectAsync<T>(IQuery query, Func<IDataReader, CancellationToken, Task<T>> converter)
Asynchronously executes a call to SQL and presents the resultant IDataReader to the supplied converter.
SqlDataReader ExecuteParameterizedSQLStatementAsReader(string sqlStatement, IEnumerable<SqlParameter> parameters, int timeoutValue = -1, bool sequentialAccess = false)
Executes a parameterized Transact-SQL statement against the connection and returns a sqlDataReader.
Executes a stored procedure against the connection and builds a DbDataReader.
Executes a stored procedure against the connection and returns the number of rows affected.
Asynchronously executes a call to SQL and presents the results as an IDataReader.
Asynchronously executes a call to SQL and returns the value in the first column of the first row in the result set
returned by the query. Additional columns or rows are ignored. The value to be returned is coerced to the struct
specified in T.
Copies data from the provided IDataReader using the provided ISqlBulkCopyParameters bulk copy parameters.
Executes a Transact-SQL statement against the connection and returns an in-memory cache of data.
Executes a parameterized Transact-SQL statement against the connection and returns an in-memory cache of data.
Executes a Transact-SQL statement against the connection and returns an in-memory cache of data.
DataSet ExecuteSqlStatementAsDataSet(string sqlStatement, IEnumerable<SqlParameter> parameters, int timeoutValue)
Executes a parameterized Transact-SQL statement against the connection and returns an in-memory cache of data.
Executes a Transact-SQL statement agains the connection and returns a table of in-memory data.
Executes a Transact-SQL statement agains the connection and returns a table of in-memory data.
Executes a parameterized Transact-SQL statement against the connection and returns a table of in-memory data.
DataTable ExecuteSqlStatementAsDataTable(string sqlStatement, int timeoutValue, IEnumerable<SqlParameter> parameters)
Executes a Transact-SQL statement agains the connection and returns a table of in-memory data.
Executes a Transact-SQL statement against the connection and builds a DbDataReader.
Executes a Transact-SQL statement against the connection and builds a DbDataReader.
DbDataReader ExecuteSqlStatementAsDbDataReader(string sqlStatement, IEnumerable<DbParameter> parameters)
Executes a Transact-SQL statement against the connection and builds a DbDataReader.
DbDataReader ExecuteSqlStatementAsDbDataReader(string sqlStatement, IEnumerable<DbParameter> parameters, int timeoutValue)
Executes a Transact-SQL statement against the connection and builds a DbDataReader.
IEnumerable<T> ExecuteSQLStatementAsEnumerable<T>(string sqlStatement, Func<SqlDataReader, T> converter, int timeout = -1)
Executes a Transact-SQL statement against the connection and returns the result as an IEnumerable<T> using the converter delegate.
Executes a Transact-SQL statement against the connection and builds a SqlDataReader.
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
T ExecuteSqlStatementAsScalar<T>(string sqlStatement, IEnumerable<SqlParameter> parameters, int timeoutValue)
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
object ExecuteSqlStatementAsScalar(string sqlStatement, IEnumerable<SqlParameter> parameters, int timeoutValue)
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
object ExecuteSqlStatementAsScalarWithInnerTransaction(string sqlStatement, IEnumerable<SqlParameter> parameters, int timeoutValue)
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
ExecuteSqlStatementAsScalarWithInnerTransaction method can be called if context.transaction is not set
This method opens transaction internally. This functionality is implemented to enable query rerun in case on the problems
with Sql optimizer hints
Executes a Transact-SQL statement against the connection and returns a table of in-memory data.
Gets a database connection.
Gets a database connection, with option to open if closed.
Gets a SqlConnection to the same database as this Context, asynchronously.
Gets a database transaction.
void ReleaseConnection()
Releases a database connection.
void RollbackTransaction()
Rolls back a database transaction.
Rolls back a database transaction. Pass in inner exception if rollback times out.