Skip to content

EasyQueryManager class

Provides basic functionality for managing different EasyQuery operations and to process the AJAX requests from EasyQuery JavaScript widgets. This class is abstract and it implements only the most common features. The descendants of this class provides more concrete implementation of the model loading and query generation

public abstract class Korzh.EasyQuery.Services.EasyQueryManager
TypeNameDescription
List<IEasyQueryManagerTuner>PreExecuteTunersThe list of tuners which are called before the query execution
IServiceProviderServicesA reference to the System.IServiceProvider object which allows you to access the DI container
TypeNameDescription
IEqCachingServiceCachingServiceGet or sets a caching service
JObjectClientDataGets a JSON object which contains all the data received from the client-side.
JObjectClientOptionsGets a JSON object which contains all the options received from the client-side.
StringDefaultModelIdGets or sets the default name of the model. This model will loaded automatically if the name was not indicated explicitly
DataModelModelGets the current model. The value of this property is set on the first call of GetModel method.
IModelLoaderModelLoaderGets or sets the model loader - an implementation of Korzh.EasyQuery.Services.IModelLoader inteface.
Action<DataModel>ModelTunerGets or sets the model tuner - a function which allows you to make some changes in the model after its loading.
PagingSettingsPagingHolds different pagination settings.
QueryQueryGets the current query. The value of this property is set on the first call of GetQuery method.
IQueryFormatsQueryFormatsGets or sets the default query formats that defines different aspects of the generated query syntax (the quotes, the type of joins in SQL, etc).
BooleanQueryRecordCountGets or sets a value indicating whether the service should send one more query to get the total number of records for the main query (when the Paging is enabed).
IQueryStoreQueryStoreGets or sets the query store - an object which covers all saving/loading operations for queries.
BooleanSaveNewQueryToStoreDetermines whether the manager should save a new query into the storage right after the creation.
BooleanSaveQueryOnSyncGets or sets a value indicating whether query will be stored on QuerySync method.
BooleanStoreModelInCacheGets or sets a value indicating whether data model will be stored in Session between requests.
BooleanStoreQueryInCacheGets or sets a value indicating whether current query will be stored in Session between requests.
StringUserIdGets or sets the user ID. This value is used to build the path to the folder where model and query files are stored. By default it’s App_Data/{UserId}/ and App_Data/{UserId}/Queries
TypeNameDescription
voidAddValueListResolver(IValueListResolver valueListResolver)Adds the value list resolver to the internal list of list resolvers which will be used during GetList request processing
QueryBuilderResultBuildQuery(JObject options = null, Boolean addPaging = False)Builds SQL statement by the DbQuery object. This methods calls QueryBuilder delegate to build SQL.
voidCheckModel()Checks if the current Model is not null and throws an exception otherwise.
voidCheckQuery()Checks if the current Query is not null and throws an exception otherwise.
DataModelCreateModelCore(String modelId)Creates the new DataModel object
Task<Query>CreateQueryAsync(String modelId = null)Creates new Query object.
QueryCreateQueryCore(DataModel model)Creates new Query object.
Task<Query>CreateQueryIfNotExistsAsync(String modelId)Creates the query if it does not exist.
IEqResultSetExecuteQuery(JObject options = null)Executes the query and returns an object which implments IEqResultSet interface.
IEqResultSetExecuteQueryCore(JObject options = null)The actual implemenation of ExecuteQuery function. This method is overridden in EasyQueryManagerBase descendants like EasyQueryManagerSql or EasyQueryManagerLinq.
TaskExportQueryResultAsync(String format, TextWriter writer)Executes the query and exports the result to a specified format. To run this operation we need to register an appropriate exporter first.
StringGenerateQueryId(String name)Generates the query identifier.
StringGetContentTypeByExportFormat(String format)Gets the content type by export format.
IDataExportSettingsGetDataExportSettings(String format)Gets the data export settings.
IDataReaderGetDataReader(JObject options = null, Boolean addPaging = False)Gets the data reader by query. This function is called from ExecuteQuery or ExportQueryResult.
Task<IEnumerable<ListItem>>GetListCoreAsync(ListRequestOptions options)The basic implemenation of GetList action handler. Can be overrided in the derived classes.
Task<DataModel>GetModelAsync(String modelId)Gets the DbModel object by ID.
Task<DataModel>GetModelCoreAsync(String modelId)The basic implementation of the GetModel action which can be overidden in the derived classes.
Task<Query>GetQueryAsync(String modelId, String queryId)Gets the Query object by name.
IQueryBuilderGetQueryBuilder(Query query, JObject options = null)Gets the registered query builder.
IQueryBuilderGetQueryBuilderCore(Query query, JObject options)
Task<Query>GetQueryCoreAsync(String modelId, String queryId)The basic implementation of the GetQuery action which can be overidden in the derived classes.
Task<IEnumerable<QueryListItem>>GetQueryListAsync(String modelId)Gets the list of available queries.
Task<IEnumerable<QueryListItem>>GetQueryListCoreAsync(String modelId)Basic implementation of Korzh.EasyQuery.Services.EasyQueryManager.GetQueryList(System.String) method. This method just calls corresponding function of the QueryStore. Can be overriden in derived classes.
StringGetValueFromCache(String key)Gets some string value from session by its key.
Task<IEnumerable<ListItem>>GetValueListAsync(String modelId, String editorId)Returns custom list of values by editorId. This method is usually called by GetList action of EasyQueryController.
TaskInitQueryAsync()Initializes the new query and saves it to the storage (if SaveNewQueryToStore is turned on).
TaskInitQueryCoreAsync()Initializes the new query. Does nothing in the base class. Can be overriden in the derived classes.
ListRequestOptionsJsonToListRequestOptions(String optionsJson)Converts JsonDict object to ListRequestOptions
BooleanLoadModelFromCache(DataModel model, String modelId)Loads DataModel from cache by ID (name)
voidLoadOptions(String optionsJson)Loads different options from JsonDict object (usually created by JSON deserialization).
BooleanLoadQueryFromCache(Query query, String queryId)Loads Query from cache by ID
TaskReadOneRequestPropertyAsync(String modelId, JsonReader reader, String propName)Read one property from a request’s JSON object.
TaskReadRequestContentFromJsonAsync(String modelId, JsonReader reader)Reads the content of the client-side request from a JsonReader object.
TaskReadRequestContentFromTextReaderAsync(String modelId, TextReader reader)Loads all reaquest’s data (like query, options, etc) from the text reader.
Task<Boolean>RemoveQueryAsync(String modelId, String queryId)Removes the query. This method uses the functionality provided by the current query store.
voidSaveModelInCache(DataModel model)Saves model into cache
voidSaveQueryInCache(Query query)Saves query into cache
Task<Boolean>SaveQueryToStoreAsync()Saves the current query to the query store.
voidSaveValueInCache(String key, String value)Stores some string value in cache.
voidSyncQuery()Synchronizes the query.
voidSyncQueryCore()Synchronizes the query. This is the default implementation which can be ovverride in derived classes.
Task<Boolean>TryLoadModelAsync(DataModel model, String modelId)Tries to load the model from the storage.
Task<Boolean>TryLoadQueryAsync(Query query, String queryId)Tries to load the query.
voidTuneBuilder(IQueryBuilder builder)Allows to tune the formats of the query builder. The default implementation calls all builder tuners defined in _builderTuners list. You can override this function in your sub-class to implement some custom behavior.
TypeNameDescription
voidRegisterExporter(String format, IDataExporter exporter)Registers ResultSet exporter for current format.