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.  [ 4 posts ] 
Author Message
 Post subject: NHibernate - Setting Null Values (Insert and Update)
PostPosted: Wed Jan 17, 2007 5:06 am 
Newbie

Joined: Sun Nov 05, 2006 10:19 am
Posts: 13
I would like to know how I can send a database null value for a field from my code; is there anything such as obj.Field = DBNull.Value

Other suggestions are welcome

Thx in advance


Top
 Profile  
 
 Post subject: Re: NHibernate - Setting Null Values (Insert and Update)
PostPosted: Wed Jan 17, 2007 7:49 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
Lorelai wrote:
I would like to know how I can send a database null value for a field from my code; is there anything such as obj.Field = DBNull.Value

Other suggestions are welcome


Have You tried using nullables of net 2.0?

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 8:20 am 
Newbie

Joined: Wed Jan 17, 2007 7:29 am
Posts: 10
In case you don't know (took me a while to find out...) nullables are created by appending ? to the typename: int?, DateTime? etc. This only works in .Net 2.0.

If you're using .Net 1.1 you can use the Nullables.* library, it's included in the NHibernate SDK.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 6:49 am 
Newbie

Joined: Mon Dec 11, 2006 12:35 pm
Posts: 1
What I do is set the property of the object to null.

vb: obj.hisproperty = nothing
c#: obj.hisproperty = null

Now if it is a datetime type of property, then the only way to go is nullable.

_________________
Rate me, but don't hate me, you nugget =)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.