NHibernate Mapping Samples

NHibernate Mapping Samples is an application containing 50 different mapping samples designed to help you with getting acquainted with NHibernate mapping both fluent and XML, since it is well-known for its complexity.

 

ExpandedToggleIcon        How to Use

NHibernate Mapping Samples application does not require any third-party software except for .NET Framework. Simply launch the application and explore our NHibernate mapping samples. You can study the classes and mapping in the application window or open a Visual Studio project for each sample to check how it works in a real application. Database creation script is available for each sample. You can also easily access NHibernate documentation page relevant to the opened sample. If you have Entity Developer for NHibernate installed, you may also open Entity Developer models that were used for the samples.

The code and mapping of these samples was generated by Entity Developer for NHibernate.

Each of the samples is a complete separate Visual Studio project that demonstrates the implementation and usage of the mapping. You can open them in Visual Studio and study how they work. You can build and debug them to study how they work on the run, view results they return, or even modify them to study how to apply such mapping case in your projects. SQLite is used as a database for the samples, and dotConnect for SQLite is used to access the database. You don't need to install any additional software, the samples contain all the necessary files to be compiled and run.

You can download NHibernate Mapping Samples from our website.

The window of the NHibernate Mapping Samples application consists of four parts.

images_nhibernate-mapping-samples-screenshot-small

1.The Samples tree lists all the available mapping cases.
2.The Mapping box contains the sample of mapping for the selected mapping case. It has two tabs - XML and Fluent, containing the corresponding mapping code.
3.The Code box contains the code of the classes, that are mapped.
4.The Description box contains the short description of the selected mapping case and links that allow you to open the sample in Visual Studio, open the model in Entity Developer, view the database script for this sample, or open the corresponding page in NHibernate documentation.

Here are some tips on how to work with our NHibernate Mapping Samples application:

To open a sample, click the corresponding node in the Samples tree (1).
To open the sample project in Visual Studio, click the "Open the sample in Visual Studio" link in the Description box (4).
To open the sample model in Entity Developer, click the "Open Entity Developer model" link in the Description box (4). You will be offered to download the Trial Edition of Entity Developer if you do not have Entity Developer installed.
To view database objects creation script, click the "View database objects creation script" link in the Description box (4).
To open the corresponding page in NHibernate documentation, click the "view relevant NHibernate help topic" link in the Description box (4).
Mapping is displayed in the Mapping box (2). Note that you can switch between the fluent and XML mapping by selecting the corresponding tabs.

 

ExpandedToggleIcon        List of the Samples

Class Mapping

Simple Class (tags used: <class>, <id>, <property>)
Computed Property (formula attribute of the <property> tag)
Version Property (tags used: <version>)
Enum Type Property (type attribute of the <property> tag)
Join Tables (tags used: <join>)
where (where attribute of the <class> tag)
filter (tags used: <filter>, <filter-def>, <filter-param>)

Class Identifier

Simple Identifier (tags used: <id>)
Composite Identifier (tags used: <composite-id>)

Associations

One-to-Many(Collection mappings)
oSimple One-to-Many (tags used: <set>, <key>, <one-to-many>, <many-to-one>)
oSimple ZeroOrOne-to-Many (tags used: <set>, <key>, <one-to-many>)
oUnique Key (tags used: <set>, <key>, <one-to-many>; property-ref attribute of the <key> tag)
oComposite Identifier (tags used: <set>, <key>, <composite-id>)
oComponent Identifier (tags used: <set>, <key>, class attribute of the <composite-id> tag)
oComponent Unique Key (tags used: <component>, <set>, <key>, property-ref attribute of the <key> tag)
oJoin Tables (tags used: <join>)
oOrder By (order-by attribute of the <set> tag, <bag>, <map>, <list>, <array>)
oWhere (where attribute of the <set> tag, <bag>, <map>, <list>, <array>)
oFilter (tags used: <filter>, <filter-def>, <filter-param>)
oCollection Of Components (tags used: <composite-element>)
oCollection Types
Set (tags used: <set>)
Bag (tags used: <bag>)
Map (tags used: <map>, <index>)
Map With Complex Index (tags used <map>, <composite-index>)
List (tags used: <list>, <index>)
Array (tags used <array>, <index>)
One-To-One
oSimple One-to-One (tags used: <one-to-one>)
oComponent Identifier (tags used: <one-to-one>, <composite-id>)
oUnique Foreign Key (property-ref attribute of the <one-to-one> tag и tags used: <many-to-one>)
oComposite Unique Foreign Key (tags used: <composite-id>; property-ref attribute of the <one-to-one>; <many-to-one>)
Many-to-Many
oSimple Many-to-Many (tags used: <many-to-many>)
oComposite Identifier (tags used: <many-to-many>, <composite-id>)
oUnique Keys (property-ref attribute of the <many-to-many> tag; property-ref attribute of the <key> tag)
oComponent Unique Keys (tags used: <component>; property-ref attribute of the <many-to-many> tag; property-ref attribute of the <key> tag)
oExtra Columns Component (tags used: <composite-element>, <many-to-one>)
oEntity Index Map (tags used: <map>, <many-to-many>, <index-many-to-many>)
oIdBag Collection (tags used: <idbag>, <many-to-many>, <collection-id>)

Components

Component Properties (tags used: <component>, <property>)
Embedded Components (tags used <component>, <property>)
Composite Identifier (tags used: <composite-id>)
Navigation properties
Many-to-one (tags used: <component>, <many-to-one>)
Many-to-many (tags used: <component>, <many-to-many>)

Inheritances

Table Per Hierarchy (tags used: <discriminator>, <subclass>)
Table Per Type (tags used: <joined-subclass>)
Table Per Concrete Class (tags used: <union-subclass>)

Named SQL Query

Without Result (tags used: <sql-query>, <query-param>)
Scalar Result (tags used: <sql-query>, <return-scalar>)
Entity Result (tags used: <sql-query>, <return>, <return-property>, <query-param>)
Complex Type Result (tags used: <sql-query>, <return>, <return-property>, <query-param>)
Execute Stored Function (tags used: <sql-query> and its attribute callable; <query-param>)

 


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.