I am using the ISqlQuery
interface of Nhibernate to fire a SQL query on database. Following is the scenario. My Domain Model has a property:
public virtual Datetime StartTime { get; set; }
The database has a column StartTime
of type DateTime2
.
I have added UserTypeConvention
for mapping code's Datetime to DB's DateTime2 and it works fine.
But when I try to query using ISqlQuery then I'm not able to set parameters to that query with the type DateTime2. If I use ISqlQuery.SetDateTime then by default it maps to DB's Datetime type and gives an exception 'SqlDateTime overflow Must be between 1 1 1753 12 00 00 AM and 12/31/9999 11:59:59 PM'.
I tried to use ISqlQuery.SetParameter("propname",datetimevalue,Nhibernate.IType)
but I couldn't find NHibernate.IType
implementation for DateTime2.
Any support for this?
Use NHibernateUtil.DateTime2