This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Why does the update SQL include the foreign key fields even though they have not been updated ? This is an example of the update code : var persistedEntity = this.RepositoryUnitOfWork.FindById<Interest>(entityId); Yet, the SQL includes updates to foreign key fields not touched by the code ... why ? Thanks. |
|
|
The ChangeTracker has no impact on the SQL generation. The ChangeTracker relates to providing you, the developer, with an accessible collection of property values for an entity. To get partial updates (only updating fields that have been changed) you would need to enable optimistic concurrency as this effectively version checks the row. Out of interest, what is the concern with updating the FK? I hope that helps, John-Daniel |
|
|
John-Daniel, Thanks for your quick response. Optimistic concurrency is on. My interest is siply that updating the foreign key causes a referential integrity check (an access to the Primary Key index of the related table) whereas this is avoided if the foriegn key is omitted from the Update.
|
|
|
Hi there, Has this question got lost down the back of the couch (along with a few fluffy Smarties) ? We really are interested to know, with the optimistic concurrency on, when clearly normal fields are only being updated when needed, why the FK fields always get updated, whether they have changed or not ? Thanks ;-) |
|
|
Hi, We've done some digging and it it seems that's just the way it was coded from get the get go. It's more related to the way that LightSpeed manages associations. Changes to associations are managed outside of how the value fields are managed which makes it quite a complex change to implement however we could optimize this in the future. Hence, we just opt-in the FK values on each update regardless of change state. I've added a ticket to the backlog for this to be worked on. John-Daniel
|
|