Optimistic Locking
-
- Posts: 5
- Joined: Mon 14 Mar 2011 15:58
Optimistic Locking
Gents could anyone point me to an implimentation of Optimistic locking using EF4 POCO objects?
The solution is to create a 'before update' trigger, and set the concurrency property in it like this:
Then set the StoreGeneratedPattern property to Computed for the version property in the Storage part of the Entity model, and set ConcurrencyMode to Fixed for this property in the Conceptual part of the model.
Code: Select all
CREATE OR REPLACE TRIGGER MyTableConcur
BEFORE UPDATE ON MyTable FOR EACH ROW
BEGIN
:NEW."Version" := :OLD."RowsetVersion" + 1;
-- alternative: :NEW."Version" := current_timestamp;
END MyTableConcur;