Skip to main content

easyquerymanagersql-class

Represents an implementation of Korzh.EasyQuery.Services.EasyQueryManager which generates SQL queries and can work with some relational DB directly.

public class Korzh.EasyQuery.Services.EasyQueryManagerSql
: EasyQueryManager

Assembly: Korzh.EasyQuery.Db.dll

Constructors

NameTypeDescription
EasyQueryManagerSql()voidInitializes a new instance of the Korzh.EasyQuery.Services.EasyQueryManagerSql class.
EasyQueryManagerSql(EasyQueryOptions options)voidInitializes a new instance of the Korzh.EasyQuery.Services.EasyQueryManagerSql class.
EasyQueryManagerSql(EasyQueryOptions options, IServiceProvider services)voidInitializes a new instance of the Korzh.EasyQuery.Services.EasyQueryManagerSql class.

Properties

NameTypeDescription
ConnectionResolverFunc<DbConnection>Gets or sets the connection resolver - a faunction that returs a connection object by model's ID.
DbCommandTunerAction<DbCommand>Gets or sets the function which is called before execution of some DbCommand.
FormatsSqlFormatsThe SQL formats.
ModelDbModelGets the current model. The value of this property is set on the first call of GetModel method.
QueryDbQueryGets the current query. The value of this property is set on the first call of GetQueryAsync method.
SqlQueryBuilderSqlQueryBuilderReturns QueryBuilder associated with current Query

Methods

NameTypeDescription
BuildQuery(QueryBuilderOptions options = null)IQueryStatementBuilds a Korzh.EasyQuery.IQueryStatement object by the Korzh.EasyQuery.Services.EasyQueryManagerSql.Query and returns the built statement.
CreateDbResultSet(IDataReader dataReader, ResultSetOptions settings)EasyDbResultSetCreates result set
CreateModelCore(string modelId = null)DataModelCreates new DataModel object
CreateQueryBuilderCore()IQueryBuilderReturns the query builder. In this particular kind of EasyQueryManager it will be an instance of SqlQueryBuilder. This method also builds the query so you can read the result via GetResult method call.
CreateQueryCore()QueryCreates new DbQuery object.
Dispose(bool disposing)voidReleases unmanaged and - optionally - managed resources.
ExportResultSetAsync(IEqResultSet data, string format, Stream stream, CancellationToken ct = null)TaskExecutes the query and exports the result to a specified format. To run this operation we need to register an appropriate exporter first.
FetchDataCoreAsync(CancellationToken ct)Task<IEqResultSet>The actual implemenation of FetchData function. This method is overridden in EasyQueryManagerBase descendants like EasyQueryManagerSql or EasyQueryManagerLinq.
GetAggregatesContainerBuilder(IReadOnlyList<EasyDataCol> dataCols, AggregationSettings aggrSettings)IAggregatesContainerBuilder
GetConnection()DbConnectionGets the DbConnection associated with this service. If connection is not defined yet - it wil be resolved using ConnectionResolver. This method opens the connection if it's not opened yet.
GetConnectionCore()DbConnectionReturns the connection object. The default implementations just calls ConnectionResolved to get the connection. You can override this function in dervived class to implement your own behavior of resolving the connnection by the model ID.
GetDataExportSettings(string format)IDataExportSettingsGets the data export settings.
GetEmptyResultSet()IEqResultSetGets any empty result set.
GetExportAggrContainer(IReadOnlyList<EasyDataCol> dataCols, IDataExportSettings settings)ExportAggrContainer
GetRecordCountAsync(CancellationToken ct = null)Task<long>Gets the record count for the current query
GetResultSetAsync(ISqlStatement statement, ResultSetOptions settings = null, `CancellationToken` ct = null)Task<IEqResultSet>Creates and returns a ResultSet object by SQL statement.
PrepareDbCommand(ISqlStatement statement, bool useCountCommand = False)DbCommandCreates and prepares the database command.
ReadClientOptions(JObject clientOptions)void
TuneDbCommand(DbCommand command)voidTunes up the DbCommand object. By default this method just calls a DbCommandTuner (if any is defined)

Static Methods

NameTypeDescription
RegisterDbGate()void