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
LinkStoreLinksList of Korzh.EasyQuery.Db.DbModel links between tables.
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.
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.
TableListTablesGets list of data model tables.
TypeNameDescription
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<DbEntity>CalcEntityPath(DbEntity entity1, DbEntity 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.
EntityCreateEntity()Creates the entity.
EntityAttrCreateEntityAttr()Creates the entity attribute. Used for creating entity attributes while building the model
EntityAttrCreateNullAttribute()Creates the null attribute.
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
EntityCreateRootEntity()Creates the root entity. This method can be overriden in descendant classes to retrun the object of appropriate class (e.g. DbEntity).
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, FillModelOptions options)Fills the model by database gate.
voidFillByDbGate(DbGate dbGate, List<String> includeTables, FillModelOptions options)Fills the model by database gate.
DbEntityLinkFindLinkByEntities(DbEntity 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, FillModelOptions options)Populates model by information from database connection.
voidLoadFromDbml(String dbmlFile)Loads the model from DBML file (Entity Framework model format).
voidLoadFromEdmx(XDocument doc)Loads model from EDMX document.
voidLoadFromEdmx(String edmxFile)Loads model from EDMX document.
voidLoadNode(XmlReader reader, RWOptions 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.
voidResetEntityContainer()
voidSaveAttributes(XmlWriter writer, RWOptions 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, RWOptions 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.