By now, you should have got a very good idea of what purpose the mappings serve. This knowledge will make understanding this section and the next very easy. At the beginning of the chapter, we discussed what is mapping by code and why it is built. So without much ado, let me get straight into the "mapping by code" feature of NH.
In mapping by code, mappings for each class can be declared in a separate and own class. It is also possible to declare the mappings in a single place by using the
ModelMapper class. We would prefer to declare mappings for each entity in its own class. This class must inherit from another class provided by NHibernate called
NHibernate.Mapping.ByCode.ClassMapping<T>. Whatever mappings you want to declare ...