EntityField2.CurrentValue migration problem

Posts   
 
    
lleo
User
Posts: 4
Joined: 13-Dec-2006
# Posted on: 20-Oct-2009 18:31:04   

Hi. I'm migrating an application from - LLBLGenPro 1.0.2005.1 release - .NET Framework 1.1 - SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll release 1.0.20051.60112 to - LLBLGenPro 2.6 release - .NET Framework 2.0 - SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll release 2.6.8.1211

One line of code in the application I'm migrating is the following:

object fieldValue = entity.Fields[1].CurrentValue;

where entity is an entity object and entity.Fields[1] is a reference to an _EntityField2 _field that is mapped on an Int32 nullable database field.

With the LLBLGenPro 1.0.2005.1 release, with the corresponding database field set to null, the result of the previous line of code was that fieldValue was 0 (the dafault value of an Int32). After migrating the code, the result is that fieldValue is null. This different behaviour breaks the rest of my application code.

The "Generate as nullable type" field's property is not checked, so I supposed the behaviour was the same as in 1.0.2005.1 release. Why the behaviour is different ? Is there any way to make the code's behaviour the same as in 1.0.2005.1 release ?

Thanks for any suggestion.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Oct-2009 05:40:10   

This is a breaking change in v2.0, so in v2.6. This is quoted from manual:

An entity field's CurrentValue property is now set to null/Nothing by default, not to a default value anymore. Also, when a field is read from the database and the value appears to be NULL, the CurrentValue property is set to null/Nothing.

The best I can recommend you is to refactor your code so it would be valid on v2.6. You of course could use backwards compatibility but you wont have the benefits of v2.6.

David Elizondo | LLBLGen Support Team
lleo
User
Posts: 4
Joined: 13-Dec-2006
# Posted on: 21-Oct-2009 08:03:37   

You of course could use backwards compatibility

What do you mean with this sentence ? Do you mean that I'd have to set SD.TemplateBindings.SharedTemplates.BackwardsCompatibility.NET20 template in the first position ?

Where I can find some documentation about which features I loose if I set backward compatibility ?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 21-Oct-2009 10:41:35   

What do you mean with this sentence ? Do you mean that I'd have to set SD.TemplateBindings.SharedTemplates.BackwardsCompatibility.NET20 template in the first position ?

yes, I think he ment that, also there are some tasks greyed out in the "task queue to execute" tab, you'll have to enable these tasks. (these are for backward compatability too).

Where I can find some documentation about which features I loose if I set backward compatibility ?

In the docs, the breaking changes of v.2.0, v.2.5 & v.2.6 are listed under the "migrating your code section".