Show / Hide Table of Contents

    Class QueryProvider

    Provider, which know execute query.

    Inheritance
    System.Object
    QueryProvider
    SqlServerQueryProvider
    Implements
    IQueryProvider
    Namespace: Kros.KORM.Query
    Assembly: Kros.KORM.dll
    Syntax
    public abstract class QueryProvider : IQueryProvider, IQueryProvider, IDisposable

    Constructors

    QueryProvider(ConnectionStringSettings, ISqlExpressionVisitor, IModelBuilder, ILogger)

    Initializes a new instance of the QueryProvider class.

    Declaration
    public QueryProvider(ConnectionStringSettings connectionSettings, ISqlExpressionVisitor sqlGenerator, IModelBuilder modelBuilder, ILogger logger)
    Parameters
    Type Name Description
    System.Configuration.ConnectionStringSettings connectionSettings

    The connection string settings.

    ISqlExpressionVisitor sqlGenerator

    The SQL generator.

    IModelBuilder modelBuilder

    The model builder.

    ILogger logger

    The logger.

    QueryProvider(DbConnection, ISqlExpressionVisitor, IModelBuilder, ILogger)

    Initializes a new instance of the QueryProvider class.

    Declaration
    public QueryProvider(DbConnection externalConnection, ISqlExpressionVisitor sqlGenerator, IModelBuilder modelBuilder, ILogger logger)
    Parameters
    Type Name Description
    System.Data.Common.DbConnection externalConnection

    The connection.

    ISqlExpressionVisitor sqlGenerator

    The SQL generator.

    IModelBuilder modelBuilder

    The model builder.

    ILogger logger

    The logger.

    Properties

    Connection

    Vráti spojenie na databázu s ktorou trieda pracuje. Ak trieda bola vytvorená iba so zadaným connection string-om, je vytvorené nové spojenie.

    Declaration
    protected DbConnection Connection { get; }
    Property Value
    Type Description
    System.Data.Common.DbConnection

    ConnectionString

    Connection string na databázu, ktorý bol zadaný pri vytvorení inštancie triedy (QueryProvider(ConnectionStringSettings, ISqlExpressionVisitor, IModelBuilder, ILogger)). Ak bola trieda vytvorená konkrétnou inštanciou spojenia, vráti null.

    Declaration
    protected string ConnectionString { get; }
    Property Value
    Type Description
    System.String

    DbProviderFactory

    Returns DbProviderFactory for current provider.

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

    IsExternalConnection

    Vráti, či spojenie na databázu je externé, tzn. či bolo explicitne zadané zvonka v konštruktore. Ak bolo spojenie zadané explicitne, vráti true, ak bol v konštruktore zadaný iba connection string a spojenie je vytvorené interne, vráti false.

    Declaration
    protected bool IsExternalConnection { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    BeginTransaction(IsolationLevel)

    Declaration
    public ITransaction BeginTransaction(IsolationLevel isolationLevel)
    Parameters
    Type Name Description
    System.Data.IsolationLevel isolationLevel
    Returns
    Type Description
    ITransaction

    CreateBulkInsert()

    Creates instance of IBulkInsert.

    Declaration
    public abstract IBulkInsert CreateBulkInsert()
    Returns
    Type Description
    IBulkInsert

    Instance of IBulkInsert.

    CreateBulkUpdate()

    Creates instance of IBulkUpdate.

    Declaration
    public abstract IBulkUpdate CreateBulkUpdate()
    Returns
    Type Description
    IBulkUpdate

    Instance of IBulkUpdate.

    CreateIdGenerator(String, Int32)

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

    CreateQuery(Expression)

    Not implemented.

    Declaration
    public IQueryable CreateQuery(Expression expression)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expression

    An expression tree that represents a LINQ query.

    Returns
    Type Description
    System.Linq.IQueryable
    Exceptions
    Type Condition
    System.NotImplementedException

    CreateQuery<TElement>(Expression)

    Constructs an System.Linq.IQueryable<T> object that can evaluate the query represented by a specified expression tree.

    Declaration
    public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expression

    An expression tree that represents a LINQ query.

    Returns
    Type Description
    System.Linq.IQueryable<TElement>

    An System.Linq.IQueryable<T> that can evaluate the query represented by the specified expression tree.

    Type Parameters
    Name Description
    TElement

    The type of the elements of the System.Linq.IQueryable<T> that is returned.

    Dispose()

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    Execute(Expression)

    Executing non generic result is not actualy supported.

    Declaration
    public object Execute(Expression expression)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expression

    An expression tree that represents a LINQ query.

    Returns
    Type Description
    System.Object
    Exceptions
    Type Condition
    System.NotImplementedException

    Execute<T>(IQuery<T>)

    Executes the specified query.

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

    Execute<TResult>(Expression)

    Executes the strongly-typed query represented by a specified expression tree.

    Declaration
    public TResult Execute<TResult>(Expression expression)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expression

    An expression tree that represents a LINQ query.

    Returns
    Type Description
    TResult

    The value that results from executing the specified query.

    Type Parameters
    Name Description
    TResult

    The type of the value that results from executing the query.

    ExecuteInTransactionAsync(Func<Task>)

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

    ExecuteNonQuery(String)

    Executes arbitrary query.

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

    Exceptions
    Type Condition
    System.ArgumentException

    Value of any of the parameters is NULL and its data type (DataType) is not set.

    ExecuteNonQueryCommand(IDbCommand)

    Executes the command.

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

    The command.

    Returns
    Type Description
    System.Int32
    Exceptions
    Type Condition
    System.NotImplementedException

    ExecuteNonQueryCommandAsync(DbCommand)

    Declaration
    public Task<int> ExecuteNonQueryCommandAsync(DbCommand command)
    Parameters
    Type Name Description
    System.Data.Common.DbCommand command
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>

    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
    public 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 null if the result set is empty. Returns a maximum of 2033 characters.

    Type Parameters
    Name Description
    T

    Type of model.

    Exceptions
    Type Condition
    System.ArgumentNullException

    If query is null.

    ExecuteStoredProcedure<TResult>(String)

    Declaration
    public TResult ExecuteStoredProcedure<TResult>(string storedProcedureName)
    Parameters
    Type Name Description
    System.String storedProcedureName
    Returns
    Type Description
    TResult
    Type Parameters
    Name Description
    TResult

    ExecuteStoredProcedure<TResult>(String, CommandParameterCollection)

    Declaration
    public TResult ExecuteStoredProcedure<TResult>(string storedProcedureName, CommandParameterCollection parameters)
    Parameters
    Type Name Description
    System.String storedProcedureName
    CommandParameterCollection parameters
    Returns
    Type Description
    TResult
    Type Parameters
    Name Description
    TResult

    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
    public DbCommand GetCommandForCurrentTransaction()
    Returns
    Type Description
    System.Data.Common.DbCommand

    Inicializovaný príkaz.

    GetCurrentTransaction()

    Gets current the transaction.

    Declaration
    protected DbTransaction GetCurrentTransaction()
    Returns
    Type Description
    System.Data.Common.DbTransaction

    Current transaction if is opened; otherwise null;

    GetSchemaLoader()

    Creates IDatabaseSchemaLoader for specific database.

    Declaration
    protected abstract IDatabaseSchemaLoader GetSchemaLoader()
    Returns
    Type Description
    IDatabaseSchemaLoader

    SetParameterDbType(DbParameter, String, String)

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

    Implements

    IQueryProvider

    See Also

    IQueryProvider
    Back to top KROS a.s.