Modelmapper Overview
The NHibernate3.2 version integrates Mapping-by-code (code mapping), and its design idea stems from conform, which is based on the "loquacious" pattern, not the "Fluent-interface". Under the NHibernate.Mapping.ByCode namespace.
mapping-by-code (code mapping) differs from other mappings, Mapping-by-code is to manually configure entity mappings, compile mappings and convert to hbmmapping object, call The void adddeserializedmapping (hbmmapping mappingdocument, String documentfilename) method of the configuration class is configured configuration , other mappings (such as fluent NHibernate, Mygeneration, Visual NHibernate, etc.) is actually called after the Addxmlreader () method is deserialized to hbmmapping object, The Adddeserializedmapping method is then called to configure configuration . Last buildsessionfactory. Mapping-path as follows:
Modelmapper Architecture
The Modelmapper core is to configure the domain model mappings, compile and convert to hbmmapping objects. According to its function the Modelmapper class has four parts, namely:
- Specific mappings (specific Mapper)
- Conformist mapping (conformist Mapping)
- event blocker (Events Interceptor)
- Compilation Mappings (compilemapping)
Specific mappings (specific Mapper)
A specific mapping (specific Mapper) that sets a custom mapping for a particular class or for a particular component. Provided by the class, subclass, Joinedsubclass, Unionsubclass, component methods.
Conformist mapping (conformist Mapping)
The Conformist map (conformist Mapping) is mapped in Class-by-class mode and then added to the Modelmapper class.
event blocker (Events Interceptor)
Event interceptors are defined before and after each mapping behavior, and constraints can be defined through event interceptors. From a design point of view, the Modelmapper class provides extensibility.
Compilation Mappings (compilemapping)
The mapping of domain entities in the program is compiled and converted to the Hbmmapping object used by NHibernate. Compilemappingfor, Compilemappingforeach methods specify domain-specific entities, The Compilemappingforallexplicitaddedentities and Compilemappingforeachexplicitaddedentity methods have explicitly specified the entity that provides the mapping.
Conclusion
This article first understands NHibernate3.2 's new Mapping-by-code (code mapping) principle, and subsequent articles learn mapping-by-code various mappings based on this article.
Copyright NOTICE: This article for Bo Master http://www.zuiniusn.com original article, without Bo Master permission not reproduced.
NHibernate anatomy: The Mapping-by-code of Mapping (1): an overview