Entity is dirty after refetching

Posts   
 
    
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 02-Jun-2009 13:18:09   

Hi Otis,

This thread was based on our conversation from thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=14195

I'll try to describe our "problem".

We have a problem with wrong behavior of IsDirty property of entitiy. We have DeviceEntity in hierarchy with it’s DeviceParentEntity in an optional PK-FK relationship. While we create new DeviceEntity we set DeviceParenId for proper value. The problem is when we open second instance of form which visulizes Devices data this new added Device is dirty.

I did something like this while adding new Device:


Main.DataServer.SaveEntity<DeviceEntity>(Main.Token, newDevice, true, true);
newDevice = Main.DataServer.FetchEntity(newDevice, PrefetchPath) as DeviceEntity;
Main.Context.Add(newDevice);

So this new added Device is now in Context. Entity now is not dirty. After that I opened second instance of this Devices form and after fetching data the last added Device was dirty. To be accurate: DeviceParentId field was changed (IsChanged was true) but CurrentValue had same value as DbValue.

We think this could be wrong behavior as after fetch from DB entity becomes dirty.

Kind regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 03-Jun-2009 10:07:38   

To be accurate: DeviceParentId field was changed (IsChanged was true) but CurrentValue had same value as DbValue.

This sounds like the core of it. Which LLBLGen Pro runtime library version are you using?

TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 03-Jun-2009 10:11:06   

Hi Walaa,

Due to a copy and paste error while creating the post for the forum, the version was not in the post, sorry for this.

I first used the runtime 28th of october 2008, but Otis asked me to use the latest runtime, so I switched to the runtime of 12th of May 2009.

Regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 03-Jun-2009 10:27:17   

To be accurate: DeviceParentId field was changed (IsChanged was true) but CurrentValue had same value as DbValue.

The important thing is: Did the CurrentValue change? regardless of the DBValue. If yes then IsChanged pf the field should be true and then IsDirty too.

TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 03-Jun-2009 10:41:59   

Hi Walaa,

I will add a trace message in the OnSetValue method and log all values for the DeviceParentId to see if I (or my code) might changed the value in between and might have triggered the IsChanged by doing this.

Unfortunately I don't have any spare time in my current sprint to test this out. I hope you can understand this.

I don't know what you prefer, that I close this thread now and reopen it when my next sprint has started or that the thread stays open?

Kind regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 03-Jun-2009 10:54:35   

Better to close it for now (I'll close it). And once you post a reply it will be automatically re-opened.

Thanks.