FieldInfoProvider has wrong system Type when field set to non-nullable?

Posts   
 
    
wojo
User
Posts: 69
Joined: 10-Mar-2004
# Posted on: 11-Aug-2006 05:33:26   

I'm running into a problem with some code that uses the IEntityField2.DataType field in an upgrade from LLBLGen 1.0 to 2.0.

Basically I turned off nullable types support for my project (for now) using the plugin Frans developed. However, my code still breaks because the DataType of a field ends up being Nullable<T> even though that support is turned off.

For example in the table ActivityStatus, the UpdateById column is nullable in the db but with the checkbox unchecked in LLBLGen to turn off the generation of a .NET nullable type. However, getting the IEntityField2 from EntityFieldFactory gives me back a DataType that says it is still Nullable<System.Int32>.

Here is the code from FieldInfoProvider.cs:

base.AddElementFieldInfo("ActivityStatusEntity", "UpdateById", typeof(Nullable<System.Int32>), false, true, false, true,  (int)ActivityStatusFieldIndex.UpdateById, 0, 0, 10);

It shouldn't be Nullable<System.Int32> but rather just System.Int32, right? I deleted that file and let it regenerate just to be sure.

Lastly, GenerateNullableFieldsAsNullableTypes in the designed project properties must only apply to new entity fields (hence the reason for the plugin)?

Thanks!!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 11-Aug-2006 10:11:25   

wojo wrote:

I'm running into a problem with some code that uses the IEntityField2.DataType field in an upgrade from LLBLGen 1.0 to 2.0.

Basically I turned off nullable types support for my project (for now) using the plugin Frans developed. However, my code still breaks because the DataType of a field ends up being Nullable<T> even though that support is turned off.

For example in the table ActivityStatus, the UpdateById column is nullable in the db but with the checkbox unchecked in LLBLGen to turn off the generation of a .NET nullable type. However, getting the IEntityField2 from EntityFieldFactory gives me back a DataType that says it is still Nullable<System.Int32>.

Here is the code from FieldInfoProvider.cs:

base.AddElementFieldInfo("ActivityStatusEntity", "UpdateById", typeof(Nullable<System.Int32>), false, true, false, true,  (int)ActivityStatusFieldIndex.UpdateById, 0, 0, 10);

It shouldn't be Nullable<System.Int32> but rather just System.Int32, right? I deleted that file and let it regenerate just to be sure.

And after generation it still showed Nullable<.. > ? Hmm... Will see if I can repro it here.

Lastly, GenerateNullableFieldsAsNullableTypes in the designed project properties must only apply to new entity fields (hence the reason for the plugin)? Thanks!!

Yes, as the general goal is to have nullable types enabled by default unless you want them to be turned off for several fields or for all fields (through the plugin), which is only the case if you're migrating from 1.0 to 2.0.

Frans Bouma | Lead developer LLBLGen Pro
wojo
User
Posts: 69
Joined: 10-Mar-2004
# Posted on: 11-Aug-2006 13:25:50   

Otis wrote:

And after generation it still showed Nullable<.. > ? Hmm... Will see if I can repro it here.

Correct.

Otis wrote:

Yes, as the general goal is to have nullable types enabled by default unless you want them to be turned off for several fields or for all fields (through the plugin), which is only the case if you're migrating from 1.0 to 2.0.

Makes sense!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 11-Aug-2006 14:09:18   

Bug, will fix it.

(edit) fixed in next build (templates)

Frans Bouma | Lead developer LLBLGen Pro