Skip to content

Query class

Represents internal query structure.

public class Korzh.EasyQuery.Query
TypeNameDescription
Condition_rootConditionThe root condition of the query
ColumnStorecolumnsList of all query columns
ColumnStorejustSortedColumnsList of just sorted coumns
StringqueryNameUser-defined name of the query
StringserializationQueryXmlSerialized query
SortedColumnListsortedColumnsList of sorted columns
TypeNameDescription
ColumnStoreColumnsGets the columns.
StringDescriptionGets or sets the query description.
StringExtraColumnsGets or sets the extra columns.
ConditionExtraConditionsGets the list of extra conditions for this query. These conditions are not visible to end-users but included into result SQL statement as all others (defined in Korzh.EasyQuery.Query.Root condition group).
ObjectExtraDataConatins user-defined extra data for current query.
StringFilePathGets the query file path. It is automatically assigned when you use LoadFromFile method.
StringIDGets or sets the ID of this query.
BooleanIsEmptyGets a value indicating whether this query is empty (no columns and no conditions are defined).
ColumnStoreJustSortedColumnsGets the list of “just sorted” columns (the columns which will occur only in ORDER BY clause)
StringLocaleIdGets or sets the locale identifier.
DataModelModelGets or sets the data model used in this query.
Func<String, DataModel>ModelResolverGets or sets the model resolver - a functions which allows to get model by its ID.
StringNameGets or sets the name of the query.
QueryParentGets the parent query.
ConditionRootGets the root condition of the query.
SortedColumnListSortedColumnsGets the list of sorted columns.
BooleanStoreModelPathGets or sets a value indicating whether this Query object should store the path to corresponding data model and restore it during query loading.
BooleanStoreOptionsGets or sets a value indicating whether this Query object should store the options and restore them during query loading.
BooleanSyncColSortOrderGets or sets a value indicating whether the order of columns must be synchronized with their sorting order.
TextStorageTextsGets an instance of TextStorage object which holds all text resources used in this assembly
Int32TimezoneOffsetTimezone offset (in minutes) for all dates used in the query
TypeNameDescription
ColumnsChangedEventHandlerColumnsChangedThis event is raised when the list of query result columns or a particular column was changed. For example some column was added or some was deleted.
ColumnsChangingEventHandlerColumnsChangingThis event is raised before the list of query columns or a particular column is going to be changed. For example some column will be added or deleted.
ConditionsChangedEventHandlerConditionsChangedThis event is raised when list of query conditions or a particular condition was changed. For example some condition was added or some - was deleted.
EventHandlerModelChangedOccurs after the model has been changed.
SortOrderChangedEventHandlerSortOrderChangedOccurs when the list of sorted columns was changed.
ConditionsChangedEventHandlerSubQueryConditionsChangedThis event is raised when list of subquery conditions or a particular condition was changed. For example some condition was added or some - was deleted.
TypeNameDescription
ColumnAddAggregateColumn(String attrId, String funcId, String caption = null, SortDirection sorting = None)Creates a new aggregate column by attribute’s ID and aggregate function nameand.
ConditionAddConditionGroup(Condition parent = null, Int32 index = -1)Creates a new condition group and adds it into the query.
ColumnAddSimpleColumn(String attrId, String caption = null, SortDirection sorting = None)Creates a new column by attribute’s ID and adds it into query.
voidBeginUpdate()Turns on the “updating” state. Any changes occured during this state will not initiate any “changed” event (like Korzh.EasyQuery.Query.ColumnsChanged or Korzh.EasyQuery.Query.ConditionsChanged) until Korzh.EasyQuery.Query.EndUpdate is called.
voidCheckDataModel()Checks the data model object. Generates an exception if Model property has null value.
voidCheckModelObject(DataModel model)Checks if model object has appropriate type and raise exception if not
voidClear()Clears the query conditions and result columns.
voidCoreClear()Clears all query content. Can be overriden in derived classes.
ColumnCreateAggregateColumn(String attrId, String funcId, String caption = null, SortDirection sorting = None)Creates an aggregate column.
AggrFuncExprCreateAggrFuncExpr(String funcID, EqExpression argumentExpr)Creates an aggregate function expression.
ColumnCreateColumn(EqExpression expr = null, String caption = null, SortDirection sortDirection = None)Creates an empty column. If expr and caption parameters are not used they must be set later (to make the new object a proper column)
ColumnCreateColumnCore()Creates the column object. Can be overridden in descendant classes
ConditionCreateConditionGroup()Creates a new condition group.
EntityAttrExprCreateEntityAttrExpr(EntityAttr attr)Creates an entity attribute expression.
EntityAttrExprCreateEntityAttrExpr(String attrId)Creates an entity attribute expression.
QueryFormatsCreateFormats()Creates an instance of QueryFormats (or its descendant).
EntityAttrExprCreateParentEntityAttrExpr(EntityAttr attr)Creates a parent entity attribute expression.
EqExpressionCreateQueryExpr()Creates a sub-query expression.
ConditionCreateRootCondition()Creates the root condition.
ConditionCreateSilentConditionGroup()Creates a new “silent” condition gropu. Here “silent” means neither this group nor its conditions will raise ConditionsChanged event in associated query
ColumnCreateSimpleColumn(EntityAttr attr, String caption = null, SortDirection sorting = None)Creates a column by EntityAttr object.
ColumnCreateSimpleColumn(String attrId, String caption = null, SortDirection sorting = None)Creates a column by EntityAttr object.
ConditionCreateSimpleCondition()Creates a simple condition.
ConditionCreateSimpleCondition(String attrId, String operatorId = null, String[] values)Creates a simple condition.
ConditionCreateSimpleCondition(String attrId, String operatorId, EqExpression[] values)Creates a simple condition.
ConditionCreateSimpleCondition(EntityAttr attr, Operator op, EqExpression[] exprs)Creates a simple condition.
QueryCreateSubQuery()Creates the subquery.
voidEndUpdate()Turns the “updating” state off.
StringGetConditionsText(QueryTextFormats formats)Returns human-readable text that represents current query conditions
QueryFormatsGetFormats()Gets query formats (an instance of Korzh.EasyQuery.QueryFormats class).
StringGetOneValueForAttr(EntityAttr attr)Gets the one value set in some query condition for indicated entity attribute
EntityGetParentQueryRootEntity()Gets the entities from parent query.
voidInnerSortOrderChanged(SortOrderChangedEventArgs e)
voidLoadFromJsonFile(String fileName, QueryReadWriteOptions rwOptions = All)Loads the query’s content from a JSON file.
TaskLoadFromJsonFileAsync(String fileName, QueryReadWriteOptions rwOptions = All)Loads the query’s content from a JSON file (asynchronous way).
voidLoadFromJsonObject(JObject jObject, QueryReadWriteOptions rwOptions = All)Loads query from Newtonsoft.Json.Linq.JObject.
TaskLoadFromJsonObjectAsync(JObject jObject, QueryReadWriteOptions rwOptions = All)Loads query from Newtonsoft.Json.Linq.JObject (asynchronous way).
voidLoadFromJsonStream(Stream stream, QueryReadWriteOptions rwOptions = All)Loads query from stream containing the JSON
TaskLoadFromJsonStreamAsync(Stream stream, QueryReadWriteOptions rwOptions = All)Loads query from stream containing the JSON (asynchronous way).
voidLoadFromJsonString(String json, QueryReadWriteOptions rwOptions = All)Loads query from string containing the JSON.
TaskLoadFromJsonStringAsync(String json, QueryReadWriteOptions rwOptions = All)Loads query from string containing the JSON (asynchronous way).
voidLoadFromXmlFile(String path, QueryReadWriteOptions options = All)Loads query from XML file.
voidLoadFromXmlReader(XmlReader reader, QueryReadWriteOptions options)Loads query from XML reader.
voidLoadFromXmlStream(Stream stream, QueryReadWriteOptions options = All)Loads query from XML stream.
voidLoadFromXmlString(String xml, QueryReadWriteOptions options = All)Loads query from XML string.
voidLoadNode(XmlReader reader, QueryReadWriteOptions rwOptions)Loads the root node.
DataModelNewModel()Creates new model object of appropriate type.
voidOnColumnsChanged(ColumnsChangeEventArgs e)Raises the ColumnsChanged event.
voidOnColumnsChanging(ColumnsChangingEventArgs e)Raises the ColumnsChanging event.
voidOnConditionsChanged(ConditionsChangeEventArgs e)Raises the ConditionsChanged event.
voidOnSortOrderChanged(SortOrderChangedEventArgs e)Raises the SortOrderChanged event.
voidOnSubQueryConditionsChanged(ConditionsChangeEventArgs e)Raises the SubQueryConditionsChanged event.
voidReadFromJson(JsonReader reader, QueryReadWriteOptions rwOptions = All)Loads query from JSON reader. Calls See Korzh.EasyQuery.Query.ReadOnePropFromJsonAsync(Newtonsoft.Json.JsonReader,System.String,Korzh.EasyQuery.QueryReadWriteOptions) function.
TaskReadFromJsonAsync(JsonReader reader, QueryReadWriteOptions rwOptions = All)Loads query from JSON reader. Calls See Korzh.EasyQuery.Query.ReadOnePropFromJsonAsync(Newtonsoft.Json.JsonReader,System.String,Korzh.EasyQuery.QueryReadWriteOptions) function.
voidReadOnePropFromJson(JsonReader reader, String propName, QueryReadWriteOptions rwOptions)Reads the property from JSON reader or skip unused.
TaskReadOnePropFromJsonAsync(JsonReader reader, String propName, QueryReadWriteOptions rwOptions)Reads the property from JSON reader or skip unused.
voidResolveDataModel(String modelId)Resolves the data model by its ID
voidResyncSortingList(Boolean changeInnerIndex)Resynchronizes the sorting list of columns correspondingly to their order.
voidSaveNodes(XmlWriter writer, QueryReadWriteOptions rwOptions)Saves the root nodes.
voidSaveToJsonFile(String filePath, QueryReadWriteOptions rwOptions = Content)Saves query to a file in JSON format.
TaskSaveToJsonFileAsync(String filePath, QueryReadWriteOptions rwOptions = Content)Saves query to a file in JSON format (asynchronous way).
JObjectSaveToJsonObject(QueryReadWriteOptions rwOptions = Content)Saves query to Newtonsoft.Json.Linq.JObject.
Task<JObject>SaveToJsonObjectAsync(QueryReadWriteOptions rwOptions = Content)Saves query to Newtonsoft.Json.Linq.JObject (asynchronous way).
voidSaveToJsonStream(Stream stream, QueryReadWriteOptions rwOptions = Content)Saves query to a stream in JSON format.
TaskSaveToJsonStreamAsync(Stream stream, QueryReadWriteOptions rwOptions = Content)Saves query to a stream in JSON format (asynchronous way).
StringSaveToJsonString(QueryReadWriteOptions rwOptions = Content)Saves query to string containing the JSON.
Task<String>SaveToJsonStringAsync(QueryReadWriteOptions rwOptions = Content)Saves query to string containing the JSON (asynchronous way).
voidSaveToXmlFile(String path, QueryReadWriteOptions options = Content)Saves query to XML file.
voidSaveToXmlStream(Stream stream, QueryReadWriteOptions options = Content)Saves query XML to stream.
StringSaveToXmlString(QueryReadWriteOptions options = Content)Saves query to string containing the XML.
voidSaveToXmlWriter(XmlWriter writer, QueryReadWriteOptions rwOptions)Saves query to XML using XML writer.
voidSetModel(DataModel newModel)Sets the data model and performs some initialization procedures.
voidValidate()Validates this query instance. This method throws an exception if query has “ghost” attributes
voidWritePropertiesToJson(JsonWriter writer, QueryReadWriteOptions rwOptions)Saves content of the query to JSON.
TaskWritePropertiesToJsonAsync(JsonWriter writer, QueryReadWriteOptions rwOptions)Saves content of the query to JSON (asynchronous way).
voidWriteToJson(JsonWriter writer, QueryReadWriteOptions rwOptions = Content)Saves query to JSON using JSON writer. Calls Korzh.EasyQuery.Query.WritePropertiesToJson(Newtonsoft.Json.JsonWriter,Korzh.EasyQuery.QueryReadWriteOptions) function.
TaskWriteToJsonAsync(JsonWriter writer, QueryReadWriteOptions rwOptions = Content)Saves query to JSON using JSON writer (asynchronous way). Calls Korzh.EasyQuery.Query.WritePropertiesToJsonAsync(Newtonsoft.Json.JsonWriter,Korzh.EasyQuery.QueryReadWriteOptions) function.