Hi mathmax,
Your best option is probably to make Quantity implement IUserType, then you can map it directly:
http://www.milkcarton.com/blog/2006/12/31/CompositeUserTypes+In+NHibernate.aspx
Alternatively, you may be able to use protected properties for the individual parts of the Weight if the Quantity class is immutable:
Code:
protected virtual float Value
{
get { return _value; }
set { _value = value; }
}
protected virtual string Unit
{
get { return _unit; }
set { _unit = value; }
}
protected virtual Quantity Weight // do not map this
{
get { return new Quantity(_unit, _value); }
set { _unit = value.Unit; _value = value.Value; }
}
Regards,
Richard