While ASP.NET performs most of its processing on the server, some actions are better served by client-side processing.
http://msdn.microsoft.com/asp.net/using/building/web/default.aspx?pull=/library/en-us/dnaspp/html/ClientSideScript.asp
With Best Regards,
Mitesh Mehta
Email : miteshvmehta@gmail.com
Wednesday, October 17, 2012
Manage Concurrency in MVC application using Entity Framework
Why Need Concurrency
Consider a case when there are two users A and B working one same record; User A opens a record to update it. He started modifying some data. But before he completes and saves updated data another user B opens the record edit it and updates the record. In this case both users get success message but as user A has updated the record lastly so his changes will preserve but the changes done by user B will get lost. This case may be acceptable for some applications but in some applications even a single change is crucial and we should handle such case very carefully.
Optimistic Concurrency (From Wiki)
Optimistic concurrency control (OCC) is a concurrency control method that assumes that multiple transactions can complete without affecting each other, and that therefore transactions can proceed without locking the data resources that they affect. Before committing, each transaction verifies that no other transaction has modified its data. If the check reveals conflicting modifications, the committing transaction rolls back.
Entity Framework provides support for optimistic concurrency model, It means when we use EF to save data in database there are no locks held on database (It has advantage of performance) but before data saved it checks in weather data from the database has been changes since it is read; if it is same then save operation completes and If it is changed it throws exception. Let us see how to use concurrency of EF in MVC application Every column in the EF table has concurrency property as show below Step 1 Create MVC 3 application. (it is assumed that you know how to create MVC 3 application) Step 2 Create Database ; While creating database table add column with name TimeStamp and data type as timestamp . Value in column with data type timestamp is updated every time a row containing a timestamp column is inserted or updated. Step 3 add ADO.NET Entity Model to the solution; After adding EF edmx file above table appears as below

Labels:
ASP.NET,
asp.net mvc,
conccurency control,
Concurrency,
MVC,
MVC concurrency
Subscribe to:
Posts (Atom)