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(KormConnectionSettings, ISqlExpressionVisitorFactory, IModelBuilder, ILogger, IDatabaseMapper)

    Initializes a new instance of the QueryProvider class.

    Declaration
    public QueryProvider(KormConnectionSettings connectionSettings, ISqlExpressionVisitorFactory sqlGeneratorFactory, IModelBuilder modelBuilder, ILogger logger, IDatabaseMapper databaseMapper)
    Parameters
    Type Name Description
    KormConnectionSettings connectionSettings

    The connection string settings.

    ISqlExpressionVisitorFactory sqlGeneratorFactory

    The SQL generator factory.

    IModelBuilder modelBuilder

    The model builder.

    ILogger logger

    The logger.

    IDatabaseMapper databaseMapper

    The Database mapper.

    QueryProvider(DbConnection, ISqlExpressionVisitorFactory, IModelBuilder, ILogger, IDatabaseMapper)

    Initializes a new instance of the QueryProvider class.

    Declaration
    public QueryProvider(DbConnection externalConnection, ISqlExpressionVisitorFactory sqlGeneratorFactory, IModelBuilder modelBuilder, ILogger logger, IDatabaseMapper databaseMapper)
    Parameters
    Type Name Description
    System.Data.Common.DbConnection externalConnection

    The connection.

    ISqlExpressionVisitorFactory sqlGeneratorFactory

    The SQL generator factory.

    IModelBuilder modelBuilder

    The model builder.

    ILogger logger

    The logger.

    IDatabaseMapper databaseMapper

    The Database mapper.

    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(KormConnectionSettings, ISqlExpressionVisitorFactory, IModelBuilder, ILogger, IDatabaseMapper)). 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 Kros.Data.BulkActions.IBulkInsert.

    Declaration
    public abstract IBulkInsert CreateBulkInsert()
    Returns
    Type Description
    Kros.Data.BulkActions.IBulkInsert

    Instance of Kros.Data.BulkActions.IBulkInsert.

    CreateBulkUpdate()

    Creates instance of Kros.Data.BulkActions.IBulkUpdate.

    Declaration
    public abstract IBulkUpdate CreateBulkUpdate()
    Returns
    Type Description
    Kros.Data.BulkActions.IBulkUpdate

    Instance of Kros.Data.BulkActions.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
    Kros.Data.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 virtual 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)

    Declaration
    public int ExecuteNonQuery(string query)
    Parameters
    Type Name Description
    System.String query
    Returns
    Type Description
    System.Int32

    ExecuteNonQuery(String, CommandParameterCollection)

    Declaration
    public int ExecuteNonQuery(string query, CommandParameterCollection parameters)
    Parameters
    Type Name Description
    System.String query
    CommandParameterCollection parameters
    Returns
    Type Description
    System.Int32

    ExecuteNonQueryAsync(String, CommandParameterCollection, CancellationToken)

    Declaration
    public Task<int> ExecuteNonQueryAsync(string query, CommandParameterCollection parameters, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.String query
    CommandParameterCollection parameters
    System.Threading.CancellationToken cancellationToken
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>

    ExecuteNonQueryAsync(String, CancellationToken)

    Declaration
    public Task<int> ExecuteNonQueryAsync(string query, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.String query
    System.Threading.CancellationToken cancellationToken
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>

    ExecuteNonQueryAsync(String, CancellationToken, Object[])

    Declaration
    public Task<int> ExecuteNonQueryAsync(string query, CancellationToken cancellationToken = default(CancellationToken), params object[] paramValues)
    Parameters
    Type Name Description
    System.String query
    System.Threading.CancellationToken cancellationToken
    System.Object[] paramValues
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>

    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, CancellationToken)

    Declaration
    public Task<int> ExecuteNonQueryCommandAsync(DbCommand command, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Data.Common.DbCommand command
    System.Threading.CancellationToken cancellationToken
    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.

    ExecuteScalarCommand(IDbCommand)

    Declaration
    public object ExecuteScalarCommand(IDbCommand command)
    Parameters
    Type Name Description
    System.Data.IDbCommand command
    Returns
    Type Description
    System.Object

    ExecuteScalarCommandAsync(DbCommand, CancellationToken)

    Declaration
    public Task<object> ExecuteScalarCommandAsync(DbCommand command, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Data.Common.DbCommand command
    System.Threading.CancellationToken cancellationToken
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Object>

    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;

    GetExpressionVisitor()

    Declaration
    public ISqlExpressionVisitor GetExpressionVisitor()
    Returns
    Type Description
    ISqlExpressionVisitor

    GetSchemaLoader()

    Creates Kros.Data.Schema.IDatabaseSchemaLoader for specific database.

    Declaration
    protected abstract IDatabaseSchemaLoader GetSchemaLoader()
    Returns
    Type Description
    Kros.Data.Schema.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

    SetQueryFilter<T>(IQuery<T>, ISqlExpressionVisitor)

    Sets the default query filter.

    Declaration
    protected void SetQueryFilter<T>(IQuery<T> query, ISqlExpressionVisitor sqlVisitor)
    Parameters
    Type Name Description
    IQuery<T> query

    The query.

    ISqlExpressionVisitor sqlVisitor

    The SQL visitor.

    Type Parameters
    Name Description
    T

    Entity type.

    SupportsIdentity()

    Returns, if provider support inserting into table, where primary key is set as Identity.

    Declaration
    public virtual bool SupportsIdentity()
    Returns
    Type Description
    System.Boolean

    Returns true.

    SupportsPrepareCommand()

    Returns, if provider supports preparing of command (System.Data.Common.DbCommand.Prepare).

    Declaration
    public virtual bool SupportsPrepareCommand()
    Returns
    Type Description
    System.Boolean

    Returns true.

    Implements

    IQueryProvider

    See Also

    IQueryProvider
    Back to top KROS a.s.