IEditableObject.CancelEdit on a new entity resets IsChanged property of every field

Posts   
 
    
Kazak1
User
Posts: 39
Joined: 30-May-2006
# Posted on: 20-Jun-2006 22:59:25   

Hi,

I'm binding an EntityCollection to a Grid control (DevExpress). The collection contains new entities only. All fields of every entity have IsChanged property set to true. When I start editing an entity in the grid and then press Escape, IEditableObject.CancelEdit method gets called on the entity. This call resets IsChanged property of every field in the selected entity to false. This leads at least to the following problems:

  • Entities will not be properly saved when persisted to the database as they have no dirty fields;
  • TestCurrentFieldValueForNull always returns true for all of the fields;

LLBLGen 1.0.2005.1 June 5th, 2006

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jun-2006 07:31:30   

I've to try it in action but it seems that this isn't tied to devexpress' grid, any grid would do.

The code indeed suggests that ischanged is set to false. What's so strange is that this code is very old, this bug must be in the code for years, so it strikes me that no-one has reported this before.

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 21-Jun-2006 08:18:30   

I guess it's not a bug.

As it's normal for the cancelEdit to set the IsChanged to false.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jun-2006 09:28:28   

Walaa wrote:

I guess it's not a bug.

As it's normal for the cancelEdit to set the IsChanged to false.

True, that's also what I was thinking when I wrote the code wink But imagine that you have a set of entities in a grid, you alter cell 'CompanyName' on row 3. You move away from the row to row 4. This means that the cell's change is final, the field is marked 'IsChanged'. Now, you move back to row 3, CompanyName, change what you wrote as you think you made a mistake, then you realize it WAS correct and hit ESC. At that moment it reverts to your changed value but IsChanged is false! simple_smile

So it should set isChanged to false only if it was false before BeginEdit.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jun-2006 10:04:58   

Reproduced.

2 entities in a grid. I change the first one's companyname, move to 2nd row. Then go back to first one's companyname cell, change it, move to another cell at THE SAME ROW, then press ESC. This causes a rollback of the entity's changes. This resets IsChanged flag on first one's Companyname field.

I'll fix this.

(edit) fixed in next build.

Frans Bouma | Lead developer LLBLGen Pro