In legacy databases, data is often spread across two or more tables, even though the rows represent one single entity. In SQL, such scenarios are handled using JOIN
constructs in the queries, and NHibernate supports this.
Add a new folder named
MappingJoins
to theMappingRecipes
project.Add a class named
Article
to the folder:namespace MappingRecipes.MappingJoins { public class Article { public virtual int Id { get; protected set; } public virtual string Title { get; set; } public virtual string Abstract { get; set; } public virtual string Author { get; set; } public virtual string FullText { get; set; } } }
Add a new embedded mapping named
Article.hbm.xml
to the folder:<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MappingRecipes" namespace="MappingRecipes.MappingJoins"> <class...