Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Generate as Nullable Type (2.0+) in ver 2.5 Designer
 

Pages: 1
Bugs & Issues
Generate as Nullable Type (2.0+) in ver 2.5 Designer
Page:1/1 

  Print all messages in this thread  
Poster Message
GizmoTN76
User



Location:

Joined on:
22-Oct-2007 18:47:51
Posted:
33 posts
# Posted on: 06-Feb-2008 01:28:22.  
I'm sure there's a setting somewhere that I can specify this but I've been pulling my hair out to find it and could use a hint as to where to look in the designer.

Right now the default behavior for class generation is to make nullable value type columns in the database nullable, and non nullable ones non nullable. Unfortunately when this happens it supplies the default values for these nonnullable ones (for instance 0 for an integer.) What I would prefer to have is all of them be nullable and then use the validation logic check to see if the user specified a value (ie pop an error provider for required fields.) It looks like the designer supports this with the (.NET 2.0+) Generate as nullable type option on the columns however this option is grayed out in the designer for the columns in my entities.

Is there a way for me to switch this on globally to automatically make everything nullable to allow for my use case? Essentially I want to let a null pass through the property to the validation (right now it just defaults it back to the default empty value and I don't have a hook to know that the value really is empty.)

I have looked for a global place other than the generation code to set framework version etc. and can't seem to locate it to turn this functionality on. The designer version I'm using shows a version number of 2.5.0.0, since this isn't really a runtime thing I don't imagine that helps.

I guess the second question would be if there is indeed a way to turn this on, what the best methodology to update every column in my project to reflect this nullable state, and how to set it for all new entities.

I'm sure I'm missing something silly here but I figured I'd throw it to the experts Regular Smiley.

Thanks in advance,

Scott
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14639 posts
# Posted on: 06-Feb-2008 11:01:06.  
Well there is no simple selectable option to create nullable types for non-nullable database fields.

You may use TypeConverters, to convert from normal .NET value types to nullable Types.


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38086 posts
# Posted on: 06-Feb-2008 13:59:39.  
This is grayed out at the moment because the target field isn't nullable. This could lead to problems when saving entities and therefore it's not possible to make these fields nullable.

You don't need to have the fields to be nullable to check if the user has set a value. Every entity has methods to test for that: TestCurrentFieldValueForNull and TestOriginalFieldValueForNull.

The first one is for testing if the user has set the field to NULL, and the second one is for testing if the field was null in the db (so doesn't apply for new entities).

If you want to test if a field is set, check its Changed flag.

I'd stay away from Nullable<T> if possible, not all .NET framework elements work OK with these types (read: winforms)
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.