Mike Taulty's Blog
Bits and Bytes from Microsoft UK
ADO.NET Data Services - Concurrency in Action

Blogs

Mike Taulty's Blog

Elsewhere

Archives

Just like for batching, there's a great explanation of how concurrency looks in ADO.NET Data Services up here so this is just a basic example.

If I take the "Hello World" style service that I built back here then it does nothing about concurrency checking because, by default, when you build an entity data model with the Entity Framework tooling all of the concurrency options are set to "off".

So, if I make a request for a customer and trace it with Fiddler then I see;

image

You can see that I'm requesting the ALFKI customer and I'm just doing it from a browser as it happens.

Now, if I go and alter my entity data model a little bit to say that ( purely for instance ) I want to have concurrency checking done on the PostalCode, Country, Region, Address fields of the Customers entity type as in;

image

image

Then the next time I request that entity I see an ETag header being emitted that contains the value of my concurrency token;

image

and if I was to request lots of customers then I'd see these ETags move into the response data as in;

image

From there, if I make an update from a client such as using .NET code like;

static void Main(string[] args)
  {
    Console.ReadLine();

    NorthwindEntities proxy = new NorthwindEntities(
      new Uri("http://mthpvista/SecureSite/Secure/Service.svc"));

    proxy.MergeOption = MergeOption.OverwriteChanges;

    Customers alfki = proxy.Customers.Where(c => c.CustomerID == "ALFKI").First();

    alfki.ContactName = "Modified";

    proxy.UpdateObject(alfki);
    proxy.SaveChanges();

    Console.ReadLine();
  }

then I can see that when we revisit the server we to make this modification we are using an If-Match header to check the concurrency token;

image

and if I was to cause a concurrency problem ( e.g. by changing the value of the city whilst the client code is running ) I'd see a 412 come back from the check on the If-Match header;

image


Posted Fri, May 30 2008 6:59 AM by mtaulty

Comments

Christopher Steen wrote Link Listing - May 31, 2008
on Sat, May 31 2008 10:14 AM
Code Camps  Save The Date: Open Spaces Mini-Conf 9 July [Via: Jim Holmes ] Link Collections  Interesting...
Christopher Steen wrote Link Listing - May 31, 2008
on Sat, May 31 2008 10:15 AM
Link Listing - May 31, 2008
Wöchentliche Rundablage: ASP.NET MVC, .NET, ADO.NET Data Services, Silverlight, WPF… | Code-Inside Blog wrote Wöchentliche Rundablage: ASP.NET MVC, .NET, ADO.NET Data Services, Silverlight, WPF… | Code-Inside Blog
on Mon, Jun 2 2008 1:33 PM
Weekly Links: ASP.NET MVC, .NET, ADO.NET Data Services, Silverlight, WPF… | Code-Inside Blog International wrote Weekly Links: ASP.NET MVC, .NET, ADO.NET Data Services, Silverlight, WPF… | Code-Inside Blog International
on Mon, Jun 2 2008 1:33 PM
Hot Topics wrote Mike Taulty beats on ADO.NET Data Services new features
on Fri, Jun 13 2008 6:27 AM
Rather than just listing what's new, Mike tries them all out! Yay Mike. First he tackles Authentication
Mike Taulty's Blog wrote Silverlight and ADO.NET Data Services ( 2 )
on Mon, Jun 30 2008 3:38 PM
Following on from this last post, if I start to edit the data in the grid and change some value then...
Jim O'Neil - Developer Evangelist wrote Azure@home Part 5: The REST of the Story
on Thu, Nov 11 2010 5:57 PM

This post is part of a series diving into the implementation of the @home With Windows Azure project