2.6 to 4.0 Migration, Field[0].CancelEdit not working

Posts   
 
    
Posts: 7
Joined: 23-Jul-2009
# Posted on: 19-Jun-2013 21:02:49   

Hi,

Wanted to migrate from 2.6 to 4.0, followed all the steps https://www.llblgen.com/pages/ListAdditionalDownloads.aspx#4

and got .llblgenproj file, generated the code but now AnEntity.Field[0].CancelEdit() does not exist, I can try using Field.CancelEdit() which still exists but is there any other good alternative I can use?

Thanks Shekhar

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Jun-2013 07:54:18   

Hi Shekhar,

Some refactoring has been made on v4. Now, to do that, you should cast to IEditableObject, something like:

((IEditableObject)AnEntity.Fields[0]).CancelEdit();

Also, it would be wise to read the Migration Guide, in case that your code face some breaking changes.

David Elizondo | LLBLGen Support Team
Posts: 7
Joined: 23-Jul-2009
# Posted on: 21-Jun-2013 00:19:29   

Hi David, I will go through the guide.

I tried your suggestion but could not cast, got this error

((IEditableObject)AnEntity.Fields[0]).CancelEdit();

Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to type 'System.ComponentModel.IEditableObject'.

Thanks Shekhar

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Jun-2013 08:13:25   

I see. Shouldn't it be like:

(IEditableObject)AnEntity).CancelEdit();

?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39912
Joined: 17-Aug-2003
# Posted on: 21-Jun-2013 12:16:54   

Indeed, call CancelEdit on the entity, as that object is edited, not the field.

We implemented IEditableObject explicitly in v3 (and onwards), to make the public interface smaller. It's not an interface you should use in your own code btw, it's meant for databinding.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 7
Joined: 23-Jul-2009
# Posted on: 25-Jun-2013 15:49:29   

Is there any way to get to the entity from the field object ? I wanted to use extension method to fix this otherwise will have to change every single file.

Thanks Shekhar

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jun-2013 03:50:00   

No.

Posts: 7
Joined: 23-Jul-2009
# Posted on: 26-Jun-2013 05:08:19   

Thanks.