These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to insert null DateTime?
PostPosted: Mon Mar 24, 2008 8:56 pm 
Newbie

Joined: Sat Feb 09, 2008 5:06 pm
Posts: 2
I'm new to NHibernate, and I'm working on a simple 3-tier web application for tasks with the new ASP.NET MVC framework and a MS SQL 2005 database.

The only problem I'm running into is inserting a null date into the database because System.DateTime cannot be null. DateTime defaults to 1/1/0001 12:00:00 AM and MS SQL 2005 requires the date to be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. When I go to save a new task NHiberante attempts to insert the invalid date of 1/1/0001 12:00:00 AM to the database.

If anyone could enlighten me how to do this I would appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 24, 2008 11:42 pm 
Newbie

Joined: Sat Feb 09, 2008 5:06 pm
Posts: 2
Apparently my mind went completely blank when it comes to dealing with DateTimes in .NET. The solution is an easy one. The type of the attribute and property need to be DateTime? in my task class and it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 10:19 am 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Hi,
How are you handling RedirectToAction and NHibernate session. I loose session so lazyload does not work. Do you have Http module that opens session on each request?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.