Skip to content

Sidecars 7, Brazil 0... - #401

Merged
ajcvickers merged 1 commit into
devfrom
FkProp703
Jul 9, 2014
Merged

ajcvickers merged 1 commit into
devfrom
FkProp703

Conversation

@ajcvickers

Copy link
Copy Markdown
Contributor

Sidecars 7, Brazil 0... (Propagate generated principal values to FKs on SaveChanges)

Some primary/principal key values are generated in the store when the entity is saved--for example, for Identity columns. These values are written back into the state entry by the update pipeline. Foreign keys that reference these principal key values also need to be updated with the generated values so that the entire graph stays in sync and so that subsequent commands issued by the update pipeline make use of the newly generated values. Also, if the save transaction is not committed, then these generated values should be discarded.

Values written into the state manager by the update pipeline are placed in a temporary transparent sidecar so that they can be discarded later. When a change is detected (or notification is made) that a principal property has changed, then the state manager now finds dependents and updates FK values appropriately. These are also written into the transparent sidecar so that the update pipeline can read them like normal values for subsequent commands, but the values can still be discarded if SaveChanges fails.

Still working on some tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding this as an overload of IModel.GetReferencingForeignKeys()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@AndriySvyryd

Copy link
Copy Markdown
Member

:shipit: Assuming no major changes are required because of my feedback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use stateManager.Model.GetReferencingForeignKeys(entityType)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

…on SaveChanges)

Some primary/principal key values are generated in the store when the entity is saved--for example, for Identity columns. These values are written back into the state entry by the update pipeline. Foreign keys that reference these principal key values also need to be updated with the generated values so that the entire graph stays in sync and so that subsequent commands issued by the update pipeline make use of the newly generated values. Also, if the save transaction is not committed, then these generated values should be discarded.

Values written into the state manager by the update pipeline are placed in a temporary transparent sidecar so that they can be discarded later. When a change is detected (or notification is made) that a principal property has changed, then the state manager now finds dependents and updates FK values appropriately. These are also written into the transparent sidecar so that the update pipeline can read them like normal values for subsequent commands, but the values can still be discarded if SaveChanges fails.

Still working on some tests.
@ajcvickers
ajcvickers merged commit 5168a4d into dev Jul 9, 2014
@ajcvickers
ajcvickers deleted the FkProp703 branch July 9, 2014 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants