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

IDBContext

public interface IDBContext
Provides a mockable interface with many common helper methods to interact with a database in a Relativity instance. Typically, you should be using the Services API to interact with Relativity, however the DBContext provides direct access to the databases when needed.
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.

void Cancel()

Tries to cancel a SQL command execution.

Commits a database transaction.

Returns a database Parameter

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.

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.

void ExecuteSqlBulkCopy(IDataReader dataReader, ISqlBulkCopyParameters bulkCopyParameters)

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

Executes a Transact-SQL statement against the connection and returns the result as an IEnumerable<T> using the converter delegate.

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.

T ExecuteSqlStatementAsObject<T>(string sqlStatement, Func<SqlDataReader, T> converter)

Executes a SQL statement that expects a single result of type T, using the provided converter.

T ExecuteSqlStatementAsObject<T>(string sqlStatement, Func<SqlDataReader, T> convertor, int timeout = -1)

Executes a SQL statement that expects a single result of type T, using the provided converter and timeout.

T ExecuteSqlStatementAsObject<T>(string sqlStatement, Func<SqlDataReader, T> converter, IEnumerable<SqlParameter> parameters)

Executes a SQL statement that expects a single result of type T, using the provided converter, set of parameters.

T ExecuteSqlStatementAsObject<T>(string sqlStatement, Func<SqlDataReader, T> converter, IEnumerable<SqlParameter> parameters, int timeoutValue)

Executes a SQL statement that expects a single result of type T, using the provided converter, set of parameters, and timeout.

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