This is a migrated thread and some comments may be shown as answers.

Tracking issue

3 Answers 124 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alexey
Top achievements
Rank 2
Alexey asked on 10 Nov 2008, 11:45 AM
For example, I have an object Store with a property Address.

If i haven't used that property before i've changed it then in ChagedEventArgs OldValue will be null.

Also it is very strange that OpenAccess loads Store address property from database once again if i will use it it my code after i have load all Store entities (SELECT [Id], [Address]       FROM [Stores]) just before:
declare @p1 int
set @p1=1
exec sp_prepexec @p1 output,N'@p0 bigint',N'SELECT [Address] FROM [Stores] WHERE [Id] = @p0  ',@p0=3
select @p1

3 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 10 Nov 2008, 11:52 AM
Hello Alexey,

We are loading data if you access it and it is not yet in memory.

This means that for us the data is not loaded when you change the property. Because you are in the call before the change actual happens and you access the property we have to load it.

I you access it after your assignment we will not load it, except we need the before value for optimistic verification.

Sincerely yours,
Jan Blessenohl
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pål
Top achievements
Rank 1
answered on 04 Feb 2009, 10:02 AM
Hi.

I stumbled accross this issue as well and did a search.

For change tracking and auditing, it is very important that the "oldValue" is reliable, since it may trigger a number of actions if changed. Also, it would be nice if you could check if the value has actually changed before raising ObjectChange events.

E.g.

Person person = GetPersistentPerson();

person.Friends = 4;    => Fires event ObjectChanged
person.Friends = 4;    => Also fires event even if it has not changed.

Any thoughts? Is there at least a way to make OA load properties before they get set so change tracking will work?

Best regards

Pål
0
Alexander
Telerik team
answered on 06 Feb 2009, 12:48 PM
Hi Pål,

The behavior you described about assigning the same value to a property can be avoided in the setter method:

public string Address 
        { 
            get { return address; } 
            set { if(address != value) 
                    address = value; 
                } 
        } 
 

That would not trigger the changed event.

The lazy loading could be also avoided with fetch plans. By using them you are able to define which properties of an object will be fetched from the database in a single transaction. You can find additional information about using Fetch plans here.

Best wishes,
Alexander
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Alexey
Top achievements
Rank 2
Answers by
Jan Blessenohl
Telerik team
Pål
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or