I can confirm that nullable datetime types work with VB. What happens when you create a Unit test just for your class where you create a new class and then populate properties and set the value of that property to nothing.
Also do you map defaults in your nhibernate config file? John Davidson On Thu, Aug 19, 2010 at 2:22 PM, Mark Wilkins <[email protected]>wrote: > I seem to be missing something wrt nullable types. > > I have a class that has a property (forgive the VB): > > Private _dateRangeFrom As Nullable(Of DateTime) > > Public Overridable Property DateRangeFrom() As Nullable(Of DateTime) > Get > Return _dateRangeFrom > End Get > Set(ByVal value As Nullable(Of DateTime)) > _dateRangeFrom = value > End Set > End Property > > > My mapping for the property is: > <property name="DateRangeFrom" /> > > The column in the database (Sql Server 2005) is a datetime that permits > nulls. > > The problem seems to be when I try to retrieve a record from the table > where DateRangeFrom is NULL. I keep getting the exception: > > NHibernate.PropertyAccessException : Invalid Cast (check your mapping > for property type mismatches); setter of > ProSanos.Works.Model.EraSelectionDef > ----> System.InvalidCastException : Specified cast is not valid. > > > I'm certain that this is the property where the exception is > occurring, since I have set breakpoints on the properties, and this is > where it fails. > > One other piece of information: when I step into the Set method of the > offending property and look at the value of the nullable type, > HasValue returns false. > > > Did I leave something out? Everything that I've found by google-ing > seems to indicate that the above code should be enough. > > Thanks, > > Mark > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
