<PackageReference Include="Relativity.Api" Version="10.3.107.60" />

IDBContext

public interface 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.
string Database { get; }

Gets a database name.

bool IsMasterDatabase { get; }

Checks if database is Master context

string ServerName { get; }

Gets a database server name.

Starts a database transaction.

Asynchronously opens a transaction against the connected SQL server.

void Cancel()

Tries to cancel a SQL command execution.

Commits a database transaction.

Returns a database Parameter

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.

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

int ExecuteNonQuerySQLStatement(string sqlStatement)

Executes a Transact-SQL statement against the connection and returns the number of rows affected.

int ExecuteNonQuerySQLStatement(string sqlStatement, int timeoutValue)

Executes a Transact-SQL statement against the connection and returns the number of rows affected.

int ExecuteNonQuerySQLStatement(string sqlStatement, IEnumerable<SqlParameter> parameters)

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.

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.

int ExecuteProcedureNonQuery(string procedureName, IEnumerable<SqlParameter> parameters)

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.

void ExecuteSqlBulkCopy(IDataReader dataReader, ISqlBulkCopyParameters bulkCopyParameters)

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.

DataSet ExecuteSqlStatementAsDataSet(string sqlStatement, int timeoutValue)

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.

DataTable ExecuteSqlStatementAsDataTable(string sqlStatement, int timeoutValue)

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.

DbDataReader ExecuteSqlStatementAsDbDataReader(string sqlStatement, int timeoutValue)

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, 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.

SqlDataReader ExecuteSQLStatementAsReader(string sqlStatement, int timeout = -1)

Executes a Transact-SQL statement against the connection and builds a SqlDataReader.

T ExecuteSqlStatementAsScalar<T>(string sqlStatement)

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)

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, 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.

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.

T ExecuteSqlStatementAsScalar<T>(string sqlStatement, SqlParameter[] parameters)

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, SqlParameter[] parameters)

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

DataTable ExecuteSQLStatementGetSecondDataTable(string sqlStatement, int timeout = -1)

Executes a Transact-SQL statement against the connection and returns a table of in-memory data.

Gets a database connection.

SqlConnection GetConnection(bool openConnectionIfClosed)

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.

Releases a database connection.

Rolls back a database transaction.

void RollbackTransaction(Exception originatingException)

Rolls back a database transaction. Pass in inner exception if rollback times out.