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

GetChanges if collection Is Managed

1 Answer 49 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Florian
Top achievements
Rank 1
Florian asked on 13 Jan 2015, 09:37 AM
Hi there

I have the following problem: I inherit the OpenAccessContext to add entries into history tables upon saving changes (slowly changing dimensions, type 4). Everytime a entity gets updated, I write an entry into a corresponding history table. For this I use the method "GetChanges().GetInserts/GetUpdates" of DataAccess.
I.e. if we update the "LastName" property of entity "Person", an entry to "HistPerson" will be written.

This has worked so far very well until I changed the collections on "Person" to IsManaged = true. Since then, I receive "false positives" when calling GetChanges on the context. I.e. if I change a persons "Diploma", also the parent "Person" (Diploma.Person) is marked as dirty (altough there are absolutely no changes - only the Diplomas-collection has an additional entry...).
I don't know if this is by design or a bug. If it's by design, I need a way to filter out the unchanged parents.

My ERD:
Person  1 <-> * Diplomas
Person  1 <-> * Licences
Licence 1 <-> * Addresses
Licence 1 <-> * Restrictions

Do you have any suggestions how to solve/workaround this problem? Are there possibilities to get the changes on a "per field" base (so then I can filter out the TrackedLists myself)?

Greetings,

Florian

1 Answer, 1 is accepted

Sort by
0
Kaloyan Nikolov
Telerik team
answered on 16 Jan 2015, 09:38 AM
Hi Florian,

The GetChanges<T>() method operate on Object level which means that it detects changes in the modified entities even they don't cause any SQL update/delete/insert statements to be executed. The reason why you see those false changes is that when the references are managed Data Access adds/removes the entities from the respective collections and thus touches the entity. Unfortunately there is not way to detect whether those changes are because the navigational properties are updated or some of the data properties are updated. 

If you can work without the managed collections then the GetChanges() method will work for your scenario.

Should you have any other questions do not hesitate to get back to us. 

Regards,
Kaloyan Nikolov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Development (API, general questions)
Asked by
Florian
Top achievements
Rank 1
Answers by
Kaloyan Nikolov
Telerik team
Share this question
or