Well,  apparently it works if the sql function is written is a lower
case form.

Map(x => x.VirtualStartDate).Formula("ISNULL(StartDate, getdate())");



On Feb 7, 11:15 am, Variant <[email protected]> wrote:
> I am trying to map a NHibernate formula for a nullable datetime field
> that would use GetDate() if the column value is null.
>
> The mapping I use is:
>
>     Map(x => x.VirtualStartDate).Formula("ISNULL(StartDate, GETDATE
> ())");
>
> in Fluent NHibernate, which translates to hbm like this:
>
>     <property name="VirtualStartDate" formula="ISNULL(StartDate,
> GETDATE ())" type="System.DateTime, mscorlib, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089" />
>
> When I try to query the database NHibernate tries to map the built-in
> GetDate() function to a column in the table:
>
>     ISNULL(workitem0_.StartDate, workitem0_.GETDATE()) as formula0_
>
> Which of course doesn't work and returns an SQL error.
> Is there any way to instruct NHIbernate that this is a built-in SQL
> function and he should leave it be?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to