entity framework - How to avoid invalid concurrent modifications in EF 4 -
i have 3-tier application:
- client application
- server application
- database server
the server uses entity framework 4 read , write data to/from database.
imagine following situation:
- client application creates instance of entity
rowversion
property. @ point in time, property equal null. - client application sends request "save instance in database" server.
- server saves object in database , automatically sets value of
rowversion
property. @ client side, value still equal null. - client application modifies object created in first step, sends request server , server gets concurrency exception when trying save new version of object.
are there standard mechanisms solving type of problem?
i dont know how system works inside (think communication between client , server goes using api). see trying handle situation when 2 clients modifying same entity , need notify client if trying save version older current.
so next:
- on step 3 server must return version id (first save of entity)
- next modification of entity client have version id , need check if current version id equal or older have on server (think rowversion timestamp)
- server logic handle states , send client response: saved new version (if current version equal , send new version id) or false state if version older (other client made modification already).
this in simplified way.
[update]
looks in article find implementation close needs: http://weblogs.asp.net/ricardoperes/archive/2012/05/28/yet-another-asp-net-mvc-crud-tutorial.aspx
Comments
Post a Comment