Hibernate version: NHibernate 1.2.0.4000
Hi,
I am having an issue with using SQL Server Stored Procedures with NHibernate:
I have a stored Proc
P_SEARCH_EVENTS defined as such:
Code:
@CountryCode as varchar(3) = null,
@RegCode as varchar(50) = null,
@StartDate as datetime = null,
@EndDate as datetime = null
Each parameter can be either assigned, or being null (and then ignored by the search query).
I am mapping the stored Proc by putting
Code:
<sql-query name="searchEvent">
<return class="Event" />
EXEC P_SEARCH_EVENTS ?, ?, ?, ?
</sql-query>
In my mapping file.
The problem is that I cant figure how to call the function in my code (My DateTime are nullable, and then unusable by query.SetDateTime. I tried query.SetParameter but it raises an exception when the object is null (since it can't guess the type)
I also tried
Code:
query.SetParameter(2, startDate, (NHibernate.Type.IType)typeof(DateTime?));
but no luck there either (not castable)
That's probably quite simple, but I couldn't figure it out with the documentation. Anyone got an idea?