Show / Hide Table of Contents

    Interface IQueryProvider

    Interface for provider, which know execute query.

    Namespace: Kros.KORM.Query
    Assembly: Kros.KORM.dll
    Syntax
    public interface IQueryProvider : IQueryProvider, IDisposable

    Properties

    DbProviderFactory

    Returns DbProviderFactory for current provider.

    Declaration
    DbProviderFactory DbProviderFactory { get; }
    Property Value
    Type Description
    System.Data.Common.DbProviderFactory

    Methods

    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.

    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.

    CreateIdGenerator(String, Int32)

    Creates the identifier generator.

    Declaration
    IIdGenerator CreateIdGenerator(string tableName, int batchSize)
    Parameters
    Type Name Description
    System.String tableName

    Name of the database table.

    System.Int32 batchSize

    Size of inserting the batch.

    Returns
    Type Description
    IIdGenerator

    The identifier generator.

    Execute<T>(IQuery<T>)

    Executes the specified query.

    Declaration
    IEnumerable<T> Execute<T>(IQuery<T> query)
    Parameters
    Type Name Description
    IQuery<T> query

    The query.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T>

    IEnumerable of models, which was materialized by query.

    Type Parameters
    Name Description
    T

    Type of model result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    If query is null.

    ExecuteInTransactionAsync(Func<Task>)

    Asynchronously executes action in transaction.

    Declaration
    Task ExecuteInTransactionAsync(Func<Task> action)
    Parameters
    Type Name Description
    System.Func<System.Threading.Tasks.Task> action

    Action which will be executed.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task that represents the asynchronous operation.

    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.

    ExecuteNonQueryCommand(IDbCommand)

    Executes the command.

    Declaration
    int ExecuteNonQueryCommand(IDbCommand command)
    Parameters
    Type Name Description
    System.Data.IDbCommand command

    The command.

    Returns
    Type Description
    System.Int32

    Number of affected rows.

    ExecuteNonQueryCommandAsync(DbCommand)

    Asynchronously executes the command.

    Declaration
    Task<int> ExecuteNonQueryCommandAsync(DbCommand command)
    Parameters
    Type Name Description
    System.Data.Common.DbCommand command

    The command.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>

    A task that represents the asynchronous save operation. The task result contains the numbers of affected rows.

    ExecuteScalar<T>(IQuery<T>)

    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
    object ExecuteScalar<T>(IQuery<T> query)
    Parameters
    Type Name Description
    IQuery<T> query

    The query.

    Returns
    Type Description
    System.Object

    The first column of the first row in the result set, or a null if the result set is empty. Returns a maximum of 2033 characters.

    Type Parameters
    Name Description
    T

    Type of model.

    ExecuteStoredProcedure<TResult>(String)

    Executes the stored procedure with parameters and returns its result. The result can be scalar value (primitive or complex – class type), or a list of values (System.Collections.Generic.IEnumerable<T>).

    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. It can be scalar primitive or complex (class) value, or System.Collections.Generic.IEnumerable<T> of some value. If the TResult is primitive scalar value, the result is converted to that. If TResult is a classs, the result of stored procedure is converted (materialized) to that class type. If TResult is System.Collections.Generic.IEnumerable<T>, the result of procedure is converted (materialized) to that.

    Examples

    For the examples, we expect to have a Database initialized and a Person class defined.

    Exceptions
    Type Condition
    System.InvalidOperationException

    ExecuteStoredProcedure<TResult>(String, CommandParameterCollection)

    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. Values of output parameters (System.Data.ParameterDirection.Output System.Data.ParameterDirection.InputOutput) are set back to corresponding parameter in collection

    Returns
    Type Description
    TResult
    Type Parameters
    Name Description
    TResult
    Exceptions
    Type Condition
    System.ArgumentException

    Value of any of the parameters in parameters is null or System.DBNull and its data type (DataType) is not set.

    GetCommandForCurrentTransaction()

    Vytvorí inicializovaný príkaz System.Data.Common.DbCommand, pre aktuálnu transakciu. Používa sa iba v rámci volania ExecuteInTransactionAsync(Func<Task>).

    Declaration
    DbCommand GetCommandForCurrentTransaction()
    Returns
    Type Description
    System.Data.Common.DbCommand

    Inicializovaný príkaz.

    SetParameterDbType(DbParameter, String, String)

    Sets correct data type to parameter, according to column columnName in table tableName. The method does not set general System.Data.Common.DbParameter.DbType, but specific for given database (SqlParameter.SqlDbType, OleDbParameter.OleDbType).

    Declaration
    void SetParameterDbType(DbParameter parameter, string tableName, string columnName)
    Parameters
    Type Name Description
    System.Data.Common.DbParameter parameter

    The parameter to which the data type is set.

    System.String tableName

    Table name.

    System.String columnName

    Column name which data type is obtained.

    Back to top KROS a.s.