Skip to content

DbModel class

Database-related implementation of Korzh.EasyQuery.DataModel class. In addition to the basic data it contains also list of database tables and the links between them.

public class Korzh.EasyQuery.Db.DbModel
: DataModel
TypeNameDescription
Dictionary<String, String>EntitySetNameType
TypeNameDescription
DbParametersDbParamsGets the Korzh.EasyQuery.Db.DbParameters object that represents different options of database linked with current data model.
StringEntityContainerNameGets the name of the default entity container. This value is used for the models created from EDMX files (Entity Framework models)
ICollection<DbEntityLink>EntityLinksGets the entity links.
BooleanIsLoadedFromDbContextGets or sets a value indicating whether this instance is loaded from a DbContext object.
LinkStoreLinksList of links between the model tables.
StringPrimaryTableNameThe name of the primary which will be used as a “root” table for this query (regardless it’s used already in any column/condition or not)
BooleanStoreDbParamsGets or sets a value indicating whether Korzh.EasyQuery.Db.DbModel.DbParams will be store in data model definition file.
TableCategoryListTableCategoriesGets the list of table categories.
TableStoreTablesGets list of data model tables.
TypeNameDescription
DbEntityAttrAddEntityAttr(Entity entity, String expression, String caption = null, Boolean isVirtual = False, DataType dataType = Int32, Int32 size = 0, Table[] tables)Adds a new attribute to the model.
voidAssignEntityAttrID(EntityAttr attr)Assigns the default ID for entity attribute.
voidAutoLinking(DbGate dbGate)This procedure finds the links between tables listed in the model (based on field names and types) and then add found links into the Korzh.EasyQuery.Db.DbModel.Links list.
List<Entity>CalcEntityPath(Entity entity1, Entity entity2)Finds a path between two entities and return it to caller as list of Enityt objects. Returns null if there is no any path between specified entities.
PathCalcPath(Table table1, Table table2)CalcPath method finds a path between tables and return it to caller or returns null if there is no any path between specified tables.
voidClear()Clears this instance.
EntityAttrCreateEntityAttr(Entity parentEntity = null, Boolean isVirtual = False)Creates an entity attribute. Used for creating entity attributes while building the model
OperatorCreateNullOperator()Creates the ‘null’ operator - a special operator which is used when a real operator can’t be found (e.g. wrong ID)
OperatorCreateOperator()Creates the operator. Used for creating objects while building the model
OperatorCreateOperator(String id, String caption, String expr, String format)Creates the operator. Used for creating objects while building the model
QueryCreateQuery(Query parentQuery = null)Creates a Query object associated with this model
DbTableCreateTableAlias(DbTable fromTable, String aliasName, Boolean createEntity = True, String entityName = null, Func<TableLink, Boolean> linkFilter = null, Func<DbEntityAttr, Boolean> entityAttrFilter = null)Creates table alias from the table.
List<String>ExcludeFieldsFromExpr(String expr)Excludes field references from some SQL expression.
voidExtractTablesByExpr(String expr, TableList tableList)Extracts all tables used in some SQL expression (like Table1.FieldName1 + Table2.FieldName2) and add them into tableList.
voidFillByDataTable(DataTable dataTable, Boolean createEntity)Fills the Korzh.EasyQuery.Db.DbModel by database table represented by System.Data.DataTable object.
voidFillByDbGate(DbGate dbGate, DbConnectionLoaderOptions options = null)Fills the model by database gate.
DbEntityLinkFindLinkByEntities(Entity entity1, Entity entity2)Finds the link by 2 entities.
EntityAttrGetDefaultUICAttribute()Returns the first attribute in the Root entity with UseInConditions set to true. This attribute is shown by default for new condition.
voidInitModelLoading()Inits the model loading.
voidLoadFromConnection(DbConnection connection, DbConnectionLoaderOptions options = null)Populates model by information from database connection.
voidLoadNode(XmlReader reader, ModelReadWriteOptions rwOptions)Loads the root node of the model. Can be overriden for loading additional root nodes in Korzh.EasyQuery.DataModel’s descendants
voidLoadOneModelAtrributeFromXmlReader(XmlReader reader)Loads one data model’s attribute from the main XML node (DataModel)
voidOnModelChanged()Called after the model has been changed.
voidOnModelLoaded()Called after the model has been loaded from some file or string.
EqExpressionPostProcessQueryExpr(QueryExpr queryExpr)Post process QueryExpr during the loading (to support the old format of XML query files)
voidReadOneModelPropFromJson(JsonReader reader, String propName)Reads one model property from JSON.
TaskReadOneModelPropFromJsonAsync(JsonReader reader, String propName)Reads one model property from JSON (asynchronous way).
voidResetEntityContainer()
voidSaveAttributes(XmlWriter writer, ModelReadWriteOptions options)Saves the attributes of the model. Can be overriden for storing additional attributes
voidSaveDbParamsNode(XmlWriter writer)Saves the Korzh.EasyQuery.Db.DbModel.DbParams node.
voidSaveLinksNode(XmlWriter writer)Saves links using System.Xml.XmlWriter object.
voidSaveNodes(XmlWriter writer, ModelReadWriteOptions options)Saves the root nodes of the model. Can be overriden for storing additional nodes
voidSaveTablesNode(XmlWriter writer)Saves tables using System.Xml.XmlWriter object.
BooleanSetTableCategory(Table table, String categoryName)Sets the category of the table. Creates a new category if the specified one does not exist yet.
voidSplitTablesIntoAliases()Splits tables into aliases
voidWriteContentToJson(JsonWriter writer, ModelReadWriteOptions rwOptions)Writes the content of DbMomdel to JSON.
TaskWriteContentToJsonAsync(JsonWriter writer, ModelReadWriteOptions rwOptions)Writes the content of DbMomdel to JSON (asynchronous way).