Interface IDatabase
Interface, which describe class for access to ORM features.
For executing query and materializing models see:
Namespace: Kros.KORM
Assembly: Kros.KORM.dll
Syntax
public interface IDatabase : IDisposable
Examples
Properties
DbProviderFactory
Returns DbProviderFactory for current provider.
Declaration
DbProviderFactory DbProviderFactory { get; }
Property Value
| Type | Description |
|---|---|
| System.Data.Common.DbProviderFactory |
ModelBuilder
Gets the model builder for materializing data from ado to models.
Declaration
IModelBuilder ModelBuilder { get; }
Property Value
| Type | Description |
|---|---|
| IModelBuilder |
Examples
Methods
BeginTransaction()
Begins the transaction.
Declaration
ITransaction BeginTransaction()
Returns
| Type | Description |
|---|---|
| ITransaction | ITransaction wrapping access to the underlying store's transaction object. |
Examples
BeginTransaction(IsolationLevel)
Begins the transaction using the specified isolation level.
Declaration
ITransaction BeginTransaction(IsolationLevel isolationLevel)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.IsolationLevel | isolationLevel | The database isolation level with which the underlying store transaction will be created. |
Returns
| Type | Description |
|---|---|
| ITransaction | ITransaction wrapping access to the underlying store's transaction object. |
Examples
CreateBulkInsert()
Creates instance of IBulkInsert.
Declaration
IBulkInsert CreateBulkInsert()
Returns
| Type | Description |
|---|---|
| IBulkInsert | Instance of IBulkInsert. |
CreateBulkUpdate()
Creates instance of IBulkUpdate.
Declaration
IBulkUpdate CreateBulkUpdate()
Returns
| Type | Description |
|---|---|
| IBulkUpdate | Instance of IBulkUpdate. |
ExecuteNonQuery(String)
Executes arbitrary query.
Declaration
int ExecuteNonQuery(string query)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Arbitrary SQL query. It should not be SELECT query. |
Returns
| Type | Description |
|---|---|
| System.Int32 | Number of affected rows. |
ExecuteNonQuery(String, CommandParameterCollection)
Executes arbitrary query with parameters.
Declaration
int ExecuteNonQuery(string query, CommandParameterCollection parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Arbitrary SQL query. It should not be SELECT query. |
| CommandParameterCollection | parameters | The query parameters. |
Returns
| Type | Description |
|---|---|
| System.Int32 | Number of affected rows. |
ExecuteScalar(String)
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.
Declaration
string ExecuteScalar(string query)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Arbitrary SQL query. |
Returns
| Type | Description |
|---|---|
| System.String | The first column of the first row in the result set, or null if the result set is empty. Returns a maximum of 2033 characters. |
ExecuteScalar(String, Object[])
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.
Declaration
string ExecuteScalar(string query, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Arbitrary SQL query. |
| System.Object[] | args | The query parameters. |
Returns
| Type | Description |
|---|---|
| System.String | The first column of the first row in the result set, or null if the result set is empty. Returns a maximum of 2033 characters. |
ExecuteScalar<TResult>(String)
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.
Declaration
TResult? ExecuteScalar<TResult>(string query)
where TResult : struct
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Arbitrary SQL query. |
Returns
| Type | Description |
|---|---|
| System.Nullable<TResult> | The first column of the first row in the result set, or null if the result set is empty. Returns a maximum of 2033 characters. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
ExecuteScalar<TResult>(String, Object[])
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.
Declaration
TResult? ExecuteScalar<TResult>(string query, params object[] args)
where TResult : struct
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Arbitrary SQL query. |
| System.Object[] | args | The query parameters. |
Returns
| Type | Description |
|---|---|
| System.Nullable<TResult> | The first column of the first row in the result set, or null if the result set is empty. Returns a maximum of 2033 characters. |
Type Parameters
| Name | Description |
|---|---|
| TResult |
ExecuteStoredProcedure<TResult>(String)
Executes the stored procedure.
Declaration
TResult ExecuteStoredProcedure<TResult>(string storedProcedureName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | storedProcedureName | Name of the stored procedure. |
Returns
| Type | Description |
|---|---|
| TResult | Result of the stored procedure. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result. |
ExecuteStoredProcedure<TResult>(String, CommandParameterCollection)
Executes the stored procedure with parameters.
Declaration
TResult ExecuteStoredProcedure<TResult>(string storedProcedureName, CommandParameterCollection parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | storedProcedureName | Name of the stored procedure. |
| CommandParameterCollection | parameters | The stored procedure parameters. |
Returns
| Type | Description |
|---|---|
| TResult | Result of the stored procedure. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result. |
InitDatabaseForIdGenerator()
Initializes database for using ID generator. Initialization can mean creating necessary table and stored procedure.
Declaration
void InitDatabaseForIdGenerator()
Query<T>()
Gets the query builder for T creating and executing query for obtains models.
Declaration
IQuery<T> Query<T>()
Returns
| Type | Description |
|---|---|
| IQuery<T> | Query builder. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of model, for which querying. |