Skip to main content

query-class

Represents internal query structure.

public class Korzh.EasyQuery.Query

Assembly: Korzh.EasyQuery.dll

Constructors

NameTypeDescription
Query(DataModel model)voidInitializes a new instance of the Korzh.EasyQuery.Query class.
Query(DataModel model, Query parentQuery)voidInitializes a new instance of the Korzh.EasyQuery.Query class.

Fields

NameTypeDescription
_rootGroupConditionThe root condition of the query
DefaultReadOptionsBitOptions
DefaultWriteOptionsBitOptions
DrillDownsDrillDownStore
serializationQueryXmlstringSerialized query
TextsTextStorageGets an instance of TextStorage object which holds all text resources used in this assembly

Properties

NameTypeDescription
AggregateSettingsAggregationSettingsGets the aggregation settings of the query. This structure can be used to define groups, totals/sub-totals and aggregates over the existing query.
AggregationAggregationSettingsGets the aggregation settings of the query. This structure can be used to define groups, totals/sub-totals and aggregates over the existing query.
AllowSyncColSortbool
ColumnsQueryColumnStoreGets the columns.
DescriptionstringGets or sets the query description.
ExtraColumnsstringGets or sets the extra columns.
ExtraConditionsConditionGets 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).
ExtraDataExpandoObjectConatains user-defined extra data for the current query.
FilePathstringGets the query file path. It is automatically assigned when you use LoadFromFile method.
IdstringGets or sets the ID of this query.
IDstringGets or sets the query identifier.
InnerDataExpandoObjectConatains some internal data (lie facets) associated with the current query.
IsDrillDownbool
IsEmptyboolGets a value indicating whether this query is empty (no columns and no conditions are defined).
IsModifiedboolIndicates whether the query was changed since the creation or the latest loading. This property is reset to false on query save.
JustSortedColumnsQueryColumnStoreGets the list of "just sorted" columns (the columns which will occur only in ORDER BY clause)
LocaleIdstringGets or sets the locale identifier.
ModelDataModelGets or sets the data model used in this query.
ModelIdstring
ModelResolverFunc<string, CancellationToken, Task<DataModel>>Gets or sets the model resolver - a functions which allows to get model by its ID.
NamestringGets or sets the name of the query.
ParentQueryGets the parent query.
RootConditionGets the root condition of the query.
SortedColumnsSortedColumnListGets the list of sorted columns.
StoreModelPathboolGets or sets a value indicating whether this Query object should store the path to corresponding data model and restore it during query loading.
StoreOptionsboolGets or sets a value indicating whether this Query object should store the options and restore them during query loading.
SyncColSortOrderboolGets or sets a value indicating whether the order of columns must be synchronized with their sorting order.
TimezoneOffsetintTimezone offset (in minutes) for all dates used in the query
UseDefaultNumericValuesboolIndicates whether we need to set the default values for numeric expressions in conditions.

Events

NameTypeDescription
ColumnsChangedColumnsChangedEventHandlerThis 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.
ColumnsChangingColumnsChangingEventHandlerThis 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.
ConditionsChangedConditionsChangedEventHandlerThis event is raised when list of query conditions or a particular condition was changed. For example some condition was added or some - was deleted.
ModelChangedEventHandlerOccurs after the model has been changed.
QueryChangedQueryChangedEventHandlerThis event is raised when there was any change in the query, either in columns, conditions or in one of the main properties (Name, Description, etc)
SortOrderChangedSortOrderChangedEventHandlerOccurs when the list of sorted columns was changed.
SubQueryConditionsChangedConditionsChangedEventHandlerThis event is raised when list of subquery conditions or a particular condition was changed. For example some condition was added or some - was deleted.

Methods

NameTypeDescription
AddAggregateColumn(string attrId, string funcId, string caption = null, SortDirection sorting = 0)QueryColumnCreates a new aggregate column by attribute's ID and aggregate function nameand.
AddColumn(IColumnDescriptor& desc)QueryColumnCreates a new column by descriptor and adds it into query.
AddConditionGroup(Condition parent = null, int index = -1)ConditionCreates a new condition group and adds it into the query.
AddDrillDown()Query
AddSimpleColumn(string attrId, string caption = null, SortDirection sorting = 0)QueryColumnCreates a new column by attribute's ID and adds it into query.
BeginUpdate()voidTurns 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.
CalculateAllowSyncColSort()bool
ChangeColumnAttr(QueryColumn column, string attrId)voidChanges the column's attribute to the one passed in the parameter
CheckDataModel()voidChecks the data model object. Generates an exception if Model property has null value.
CheckModelObject(DataModel model)voidChecks if model object has appropriate type and raise exception if not
CleanUp()voidClean up this query instance. This method removes columns and conditions with "ghost" attributes or operators
Clear()voidClears the query conditions and result columns.
CoreClear()voidClears all query content. Can be overriden in derived classes.
CreateAggregateColumn(string attrId, string funcId, string caption = null, SortDirection sorting = 0)QueryColumnCreates an aggregate column.
CreateAggrFuncExpr(string funcID, EqExpression argumentExpr)AggrFuncExprCreates an aggregate function expression.
CreateColumn(EqExpression expr = null, `string` caption = null, SortDirection sortDirection = 0)QueryColumnCreates an empty column. If expr and caption parameters are not used they must be set later (to make the new object a proper column)
CreateColumn(IColumnDescriptor& modreq(System.Runtime.InteropServices.InAttribute) desc)QueryColumnCreates an empty column. If expr and caption parameters are not used they must be set later (to make the new object a proper column)
CreateColumnCore()QueryColumnCreates the column object. Can be overridden in descendant classes
CreateConditionGroup()ConditionCreates a new condition group.
CreateEntityAttrExpr(EntityAttr attr)EntityAttrExprCreates an entity attribute expression.
CreateEntityAttrExpr(string attrId)EntityAttrExprCreates an entity attribute expression.
CreateParentColumnExpr(QueryColumn column, string name = )ParentColumnExprCreates a parent column expression.
CreateParentColumnExpr(string columnId, string name = )ParentColumnExprCreates a parent column expression.
CreateParentEntityAttrExpr(EntityAttr attr)EntityAttrExprCreates a parent entity attribute expression.
CreateQueryExpr()EqExpressionCreates a sub-query expression.
CreateRootCondition()ConditionCreates the root condition.
CreateSilentConditionGroup()ConditionCreates a new "silent" condition gropu. Here "silent" means neither this group nor its conditions will raise ConditionsChanged event in associated query
CreateSimpleColumn(EntityAttr attr, string caption = null, SortDirection sorting = 0)QueryColumnCreates a column by EntityAttr object.
CreateSimpleColumn(string attrId, string caption = null, SortDirection sorting = 0)QueryColumnCreates a column by EntityAttr object.
CreateSimpleCondition()ConditionCreates a simple condition.
CreateSimpleCondition(string attrId, string operatorId = null, String[] values)ConditionCreates a simple condition.
CreateSimpleCondition(string operatorId = null, EqExpression[] expressions)ConditionCreates a simple condition.
CreateSimpleCondition(EntityAttr attr, Operator op, String[] values)ConditionCreates a simple condition.
CreateSimpleCondition(string attrId, string operatorId, EqExpression[] values)ConditionCreates a simple condition.
CreateSimpleCondition(EntityAttr attr, Operator op, EqExpression[] exprs)ConditionCreates a simple condition.
CreateSubQuery()QueryCreates the subquery.
EndUpdate()voidTurns the "updating" state off.
GetConditionsText(QueryTextFormats formats)stringReturns human-readable text that represents current query conditions
GetOneValueForAttr(EntityAttr attr)stringGets the one value set in some query condition for indicated entity attribute
GetParentQueryRootEntity()EntityGets the entities from parent query.
LoadFromJsonFile(string filePath)voidLoads the query's content from a JSON file.
LoadFromJsonFile(string filePath, BitOptions rwOptions)voidLoads the query's content from a JSON file.
LoadFromJsonFileAsync(string fileName, CancellationToken ct = null)TaskLoads the query's content from a JSON file (asynchronous way).
LoadFromJsonFileAsync(string fileName, BitOptions rwOptions, CancellationToken ct = null)TaskLoads the query's content from a JSON file (asynchronous way).
LoadFromJsonObject(JObject jObject)voidLoads query from Newtonsoft.Json.Linq.JObject.
LoadFromJsonObject(JObject jObject, BitOptions rwOptions)voidLoads query from Newtonsoft.Json.Linq.JObject.
LoadFromJsonObjectAsync(JObject jObject, CancellationToken ct = null)TaskLoads query from Newtonsoft.Json.Linq.JObject (asynchronous way).
LoadFromJsonObjectAsync(JObject jObject, BitOptions rwOptions, CancellationToken ct = null)TaskLoads query from Newtonsoft.Json.Linq.JObject (asynchronous way).
LoadFromJsonStream(Stream stream)voidLoads query from stream containing the JSON
LoadFromJsonStream(Stream stream, BitOptions rwOptions)voidLoads query from stream containing the JSON
LoadFromJsonStreamAsync(Stream stream, CancellationToken ct = null)TaskLoads query from stream containing the JSON (asynchronous way).
LoadFromJsonStreamAsync(Stream stream, BitOptions rwOptions, CancellationToken ct = null)TaskLoads query from stream containing the JSON (asynchronous way).
LoadFromJsonString(string json)voidLoads query from string containing the JSON.
LoadFromJsonString(string json, BitOptions rwOptions)voidLoads query from string containing the JSON.
LoadFromJsonStringAsync(string json, CancellationToken ct = null)TaskLoads query from string containing the JSON (asynchronous way).
LoadFromJsonStringAsync(string json, BitOptions rwOptions, CancellationToken ct = null)TaskLoads query from string containing the JSON (asynchronous way).
LoadFromXmlFile(string path)voidLoads query from XML file.
LoadFromXmlFile(string path, BitOptions options)voidLoads query from XML file.
LoadFromXmlReader(XmlReader reader)voidLoads query from XML reader.
LoadFromXmlReader(XmlReader reader, BitOptions options)voidLoads query from XML reader.
LoadFromXmlStream(Stream stream)voidLoads query from XML stream.
LoadFromXmlStream(Stream stream, BitOptions options)voidLoads query from XML stream.
LoadFromXmlString(string xml)voidLoads query from XML string.
LoadFromXmlString(string xml, BitOptions options)voidLoads query from XML string.
LoadNode(XmlReader reader, BitOptions rwOptions)voidLoads the root node.
NewModel()DataModelCreates new model object of appropriate type.
OnSortOrderChanged(SortOrderChangedEventArgs e)voidRaises the SortOrderChanged event.
OnSubQueryConditionsChanged(ConditionsChangeEventArgs e)voidRaises the SubQueryConditionsChanged event.
ReadFromJson(JsonReader reader)voidLoads query from JSON reader. Calls See function.
ReadFromJson(JsonReader reader, BitOptions rwOptions)voidLoads query from JSON reader. Calls See function.
ReadFromJsonAsync(JsonReader reader, CancellationToken ct = null)TaskLoads query from JSON reader. Calls See Korzh.EasyQuery.Query.ReadOnePropFromJsonAsync(Newtonsoft.Json.JsonReader,System.String,EasyData.BitOptions,System.Threading.CancellationToken) function.
ReadFromJsonAsync(JsonReader reader, BitOptions rwOptions, CancellationToken ct = null)TaskLoads query from JSON reader. Calls See Korzh.EasyQuery.Query.ReadOnePropFromJsonAsync(Newtonsoft.Json.JsonReader,System.String,EasyData.BitOptions,System.Threading.CancellationToken) function.
ReadOnePropFromJsonAsync(JsonReader reader, string propName, BitOptions rwOptions, CancellationToken ct)TaskReads the property from JSON reader or skip unused.
ResolveDataModelAsync(string modelId, CancellationToken ct)TaskResolves the data model by its ID
SaveNodes(XmlWriter writer, BitOptions rwOptions)voidSaves the root nodes.
SaveToJsonFile(string filePath)voidSaves query to a file in JSON format.
SaveToJsonFile(string filePath, BitOptions rwOptions)voidSaves query to a file in JSON format.
SaveToJsonFileAsync(string filePath, CancellationToken ct = null)TaskSaves query to a file in JSON format (asynchronous way).
SaveToJsonFileAsync(string filePath, BitOptions rwOptions, CancellationToken ct = null)TaskSaves query to a file in JSON format (asynchronous way).
SaveToJsonObject()JObjectSaves query to Newtonsoft.Json.Linq.JObject.
SaveToJsonObject(BitOptions rwOptions)JObjectSaves query to Newtonsoft.Json.Linq.JObject.
SaveToJsonObjectAsync(CancellationToken ct = null)Task<JObject>Saves query to Newtonsoft.Json.Linq.JObject (asynchronous way).
SaveToJsonObjectAsync(BitOptions rwOptions, CancellationToken ct = null)Task<JObject>Saves query to Newtonsoft.Json.Linq.JObject (asynchronous way).
SaveToJsonStream(Stream stream)voidSaves query to a stream in JSON format.
SaveToJsonStream(Stream stream, BitOptions rwOptions)voidSaves query to a stream in JSON format.
SaveToJsonStreamAsync(Stream stream, CancellationToken ct = null)TaskSaves query to a stream in JSON format (asynchronous way).
SaveToJsonStreamAsync(Stream stream, BitOptions rwOptions, CancellationToken ct = null)TaskSaves query to a stream in JSON format (asynchronous way).
SaveToJsonString()stringSaves query to string containing the JSON.
SaveToJsonString(BitOptions rwOptions)stringSaves query to string containing the JSON.
SaveToJsonStringAsync(CancellationToken ct = null)Task<string>Saves query to string containing the JSON (asynchronous way).
SaveToJsonStringAsync(BitOptions rwOptions, CancellationToken ct = null)Task<string>Saves query to string containing the JSON (asynchronous way).
SaveToXmlFile(string path)voidSaves query to XML file.
SaveToXmlFile(string path, BitOptions options)voidSaves query to XML file.
SaveToXmlStream(Stream stream)voidSaves query XML to stream.
SaveToXmlStream(Stream stream, BitOptions options)voidSaves query XML to stream.
SaveToXmlString()stringSaves query to string containing the XML.
SaveToXmlString(BitOptions options)stringSaves query to string containing the XML.
SaveToXmlWriter(XmlWriter writer)voidSaves query to XML using XML writer.
SaveToXmlWriter(XmlWriter writer, BitOptions rwOptions)voidSaves query to XML using XML writer.
SetModel(DataModel newModel)voidSets the data model and performs some initialization procedures.
Validate()voidValidates this query instance. This method throws an exception if query has "ghost" attributes
WritePropertiesToJsonAsync(JsonWriter writer, BitOptions rwOptions, CancellationToken ct)TaskSaves content of the query to JSON (asynchronous way).
WriteToJson(JsonWriter writer)voidSaves query to JSON using JSON writer.
WriteToJson(JsonWriter writer, BitOptions rwOptions)voidSaves query to JSON using JSON writer.
WriteToJsonAsync(JsonWriter writer, CancellationToken ct = null)TaskSaves query to JSON using JSON writer (asynchronous way). Calls Korzh.EasyQuery.Query.WriteToJsonAsync(Newtonsoft.Json.JsonWriter,EasyData.BitOptions,System.Threading.CancellationToken) function.
WriteToJsonAsync(JsonWriter writer, BitOptions rwOptions, CancellationToken ct = null)TaskSaves query to JSON using JSON writer (asynchronous way). Calls Korzh.EasyQuery.Query.WriteToJsonAsync(Newtonsoft.Json.JsonWriter,EasyData.BitOptions,System.Threading.CancellationToken) function.