Testing concurrency with WCF Test Client
Now we have concurrent support added to the service let's test it with the built-in WCF Test Client.
Press Ctrl + F5 to start the program. Click on GetProduct, enter a valid product ID, and then click on the Invoke button to get the product details. You should have a screen like the following image.
From this image we know the product, RowVersion
, is returned from the database to the client. It is of the Byte[]
type.
Now click on UpdateProduct and enter the same product ID, a new name, quantity per unit, and unit price. However, you can't enter a value to the RowVersion
field for this update because it is of the byte[]
type.
If you click on the Invoke button to call the service you will get an exception like this:
From this image we can see that the update failed due to concurrency control (actually a concurrency exception is thrown in the data access layer). The reason is that we didn't pass in the original RowVersion
for the object to be updated and...