Workspace is an entity which implements data isolation. It contains and tracks all changes made to the data, isolated from other workspaces. Also, changes from other workspaces and commits are not visible from a workspace after it was
When workspace is opened, isolation level needs to be defined:
- Read only isolation - all workspace operations are restricted to data reading
- Snapshot isolation - workspace data can be read and modified concurrently with other workspaces
- Exclusive isolation - workspace data can be modified exclusive to other workspaces. Reading is still possible from other workspaces
It is recommended that lowest applicable level is used for optimal performance.
Once created, workspace can be accessed only by the thread which has created it. Multiple workspaces may be opened by a given thread.
Following operations are most used when working with workspace:
- Data - property which provides access to entire object graph
- New - creates new object
- ImmutableView - get immutable view of any entity in the model
- Commit - pushes changes to Context making them public
- Rollback - cancels changes and reverts back to last commited state
- Update - forwards workspace to new data version, which assumes there are no uncommited conflicting changes in the workspace
- TryUpdate - forwards workspace to new data version, which aborts when uncommited conflicting changes have been made in the workspace
Workspace implements IDisposable, which means Dispose should be called after operation with workspace is completed, or it should be declared within an using block.