C# – NHibernate mapping after a normalisation

cfluent-nhibernatenhibernatenhibernate-mapping

Please help me – I'm new to NHibernate and I cannot seem to find what I'm looking for.

I have two tables in a database: Fund and FundBalance. A Fund can have many FundBalances and a FundBalance has only one Fund.

In C#, there is only the FundBalance class. Columns from the Fund table joined with columns from the FundBalance table need to be mapped onto properties of the FundBalance class.

For example, the Fund table contains the FundName property and the FundBalance table contains the AvailableBalance property. These two tables are joined and the result of the join needs to be mapped to the FundName and AvailableBalance properties on the FundBalance class.

The question: how do I do this with NHibernate? Bonus: How do I specify the mapping using FluentNHibernate?

One solution that I thought of was to create a view in the database, but I would prefer it if the mapping can be done purely using NHibernate.

Best Answer

As I've asked in the comments; how does this FundBalance class exactly looks like ? What goes in there ? Can you do something with the <join table> element in the NHibernate mapping ?

For example: http://ayende.com/Blog/archive/2007/04/24/Multi-Table-Entities-in-NHibernate.aspx