The EntityMapper class
Glossary Item Box
Introduction
The Terrasoft.Configuration.EntityMapper class is a utility configuration class that stored in the [FinAppLending] package of the Lending product. EntittyMapper allows to map data of one Entity with another using rules defined in the configuration file. Using the approach of mapping the data of different entities avoids the appearance of a monotonous code.
The idea of mapping the data of different entities is implemented in the following classes:
- EntityMapper – implements the mapping logic.
- EntityResult – defines the resulting type of the mapped entity.
- MapConfig – a set of mapping rules.
- DetailMapConfig – used to set up a list of mapping rules of the details and entities connected with them.
- RelationEntityMapConfig – contains rules for mapping connected entities.
- EntityFilterMap – a filter for database query.
The “Terrasoft.Configuration.EntityMapper“ class
Use the “.NET class libraries of platform core” documentation to access the full list of the EntityMapper class methods, its parent classes and the implemented interfaces.
Methods
Table 1. Primary methods of the EntityMapper class
- virtual EntityResult GetMappedEntity((Guid recId, MapConfig config))
-
Returns mapped data for two Entity objects.
Parameters:
- recId – GUID records in the database;
- config – an instance of the MapConfig class, which is a set of mapping rules.
- virtual Dictionary<string, object> GetColumnsValues((Guid recordId, MapConfig config, Dictionary<string, object> result))
-
Gets the main entity from the database and matches its columns and values according to the rules specified in the config object.
Parameters:
- recordId – GUID recodrs in the database;
- config – an instance of the MapConfig class, which is a set of mapping rules;
- result – a dictionary of columns and their values of the mapped entity.
- virtual Dictionary<string, object> GetRelationEntityColumnsValues((List<RelationEntityMapConfig> relations, Dictionary<string, object> dictionaryToMerge, string columnName, Terrasoft.Nui.ServiceModel.DataContract.LookupColumnValue entitylookup))
-
Gets the related entities from the database and matches them to the main entities.
Parameters:
- relations – a list of rules for obtaining related records;
- dictionaryToMerge – a dictionary with columns and theirs values;
- columnName – name of the parent column;
- entitylookup – an object that contains name and Id of the record in the database.
The “Terrasoft.Configuration.EntityResult“ class
Use the “.NET class libraries of platform core” documentation to access the full list of the EntityResult class properties, its parent classes and the implemented interfaces.
Properties
Table 2. Primary methods of the EntityResult class
- Columns
- Dictionary<string, object>
-
A dictionary of main entity column names and their values.
- Details
- Dictionary<string, List<Dictionary<string, object>>>
-
A dictionary of the detail names with the list of their columns and values.
The “Terrasoft.Configuration.MapConfig“ class
Use the “.NET class libraries of platform core” documentation to access the full list of the MapConfig class properties, its parent classes and the implemented interfaces.
Properties
Table 3. Primary methods of the MapConfig class
- SourceEntityName
- string
-
Entity name in the database.
- Columns
- Dictionary<string, object>
-
A dictionary with the names of columns of one entity and compared columns of another entity.
- DetailsConfig
- List<DetailMapConfig>
-
A list of configuration objects with rules for details.
- CleanDetails
- List<string>
-
A list of detail names for cleaning their values.
- RelationEntities
- List<RelationEntityMapConfig>
-
List of configuration objects with rules for mapping related records with the main entity.
The “Terrasoft.Configuration.DetailMapConfig“ class
Use the “.NET class libraries of platform core” documentation to access the full list of the DetailMapConfig class properties, its parent classes and the implemented interfaces.
Properties
Table 4. Primary methods of the DetailMapConfig class
- DetailName
- string
-
Detail name (The ensure the uniqueness of detail instance).
- SourceEntityName
- string
-
Entity name in the database.
- Columns
- Dictionary<string, object>
-
A dictionary with the names of columns of one entity and compared columns of another entity.
- Filters
- List<EntityFilterMap>
-
A list of configuration objects with filtration rules for more accurate selections from the database.
- RelationEntities
- List<RelationEntityMapConfig>
-
List of configuration objects with rules for mapping related records with the main entity.
The “Terrasoft.Configuration.RelationEntityMapConfig“ class
Use the “.NET class libraries of platform core” documentation to access the full list of the RelationEntityMapConfig class properties, its parent classes and the implemented interfaces.
Properties
Table 5. Primary methods of the RelationEntityMapConfig class
- ParentColumnName
- string
-
The name of the parent column, which, when found, will trigger the logic for obtaining and mapping the entity data.
- SourceEntityName
- string
-
Entity name in the database.
- Columns
- Dictionary<string, object>
-
A dictionary with the names of columns of one entity and compared columns of another entity.
- Filters
- List<EntityFilterMap>
-
A list of configuration objects with filtration rules to refine selections from the database.
- RelationEntities
- List<RelationEntityMapConfig>
-
List of configuration objects with rules for mapping related records with the main entity.
The “Terrasoft.Configuration.EntityFilterMap“ class
Use the “.NET class libraries of platform core” documentation to access the full list of the EntityFilterMap class properties, its parent classes and the implemented interfaces.
Properties
Table 6. Primary methods of the EntityFilterMap class
- ColumnName
- string
-
The name of the column, which when found, will start the filtering logic.
- Value
- object
-
The value to compare to.