I\'m using Fluent NHibernate and have two tables;
Customer [ID, Name, LanguageID]
Languages [ID, Description]
I have a Customer entity with the following
I think you can create an Entity for Language. Later in the Entity for Customer have a reference to that Entity.
public class Customer
{
public virtual int Id { get; set; }
public virtual string Name{ get; set; }
public virtual Language Language { get; set; }
}
Then in the CutomerMap you should do:
public class CustomerMap : ClassMap
{
public CustomerMap()
{
Id(x => x.Id);
Map(x => x.Name);
References(x => x.Language);
}
}
Later when you call your costumers you can decide show the "instance.Language.Description"
For example in MVC, in the controller you can do:
public ActionResult Index()
{
using (ISession session = NHibernateHelper.OpenSession())
{
var customers = session.Query().Fetch(x => x.Language).ToList();
return View(customers);
}
}
And in the View:
@foreach (var item in Model) {
@Html.DisplayFor(modelItem => item.Name)
@Html.DisplayFor(modelItem => item.Language.Description)
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
}
Hope this helps.