Nhibernate – property with formula (cont.)

First, I have to split this post in 2, becuase Spaces can’t handle 2 pages of text in one post. I really have to switch to some other means of blogging…

 

Anyways, I received a request for a sample of formula mapping and since I wasn’t any longer with the company/project where I noticed this behaviour I decided to implement if "from scratch" – using NHibernate from the SVN trunk, Northwind and C# 3.0 (why not?).

 

It turned into quite an exercise, but long story short: it’s not as simple and not as nice as I thought.

Here’s the final code example:

Mapping:

—————————————————————————–

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

<class name="PropertyFormulaExample.Shipper, PropertyFormulaExample" table="Shippers" lazy="false" >

<id name="ShipperID" column="ShipperID" unsaved-value="0">

<generator class="native" />

</id>

<property name="CompanyName" column="CompanyName" />

<property name="Phone" column="Phone" />

</class>

</hibernate-mapping>

 

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

<class name="PropertyFormulaExample.Order, PropertyFormulaExample" table="Orders" lazy="false">

<id name="OrderID" column="OrderID" unsaved-value="0">

            <generator class="native" />

</id>

<property name="CustomerID" column="CustomerID" />

<property name="ShipVia" type="PropertyFormulaExample.Shipper, PropertyFormulaExample" formula="dbo.GetShipper(shipvia)" />

</class>

</hibernate-mapping>

—————————————————————————–

 

(to  be continued …)

 

Advertisements
Nhibernate – property with formula (cont.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s