Formula Column Insertability and Updatability

14 views
Skip to first unread message

Wildjoe182

unread,
Aug 11, 2011, 2:01:28 AM8/11/11
to nhusers
In NHibernate, is it possible to have a formula column which queries
using said formula, but still have the column mapped to an actual
column name so that I can update and insert the actual column value in
the database?

Something like:
<property name="UnitType" insert="true" update="true" formula="CASE
WHEN [type] in ('U', 'P') THEN [type] ELSE NULL END"
type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"">
<column name="type" not-null="false" />
</property>

The common excuses apply: Bad legacy database; can't change data;
can't add constraints, can't...

Regards,

Joe

allan....@gmail.com

unread,
Aug 11, 2011, 8:12:14 AM8/11/11
to nhusers
You could use event listeners to calculate these values going in/out
of the db and skip the formula altogether.

Fabio Maulo

unread,
Aug 12, 2011, 8:37:00 AM8/12/11
to nhu...@googlegroups.com
The RDBMS is there just because an IT accident.

<property name="type" access="field" not-null="false" /> 

private string type;
public System.Type UnitType
{
get
{
if(type == "U" || type == 'P')
return typeof(string);
else
return null;
}
}
Reply all
Reply to author
Forward
0 new messages