0

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?

0

1 Answer 1

1

Just solved it myself, apparently it works if the sql function is written is a lower case form.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.