NHibernate anatomy: The Mapping-by-code of Mapping (1): an overview

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.