Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Optimistic Concurrency in Entity Framework

$
0
0

Hi,


I'm trying a way to recognize if another client has changed a record on the database while I have it open.
Example:

http://www.binaryintellect.net/articles/58216146-d464-42cb-b60d-15215467b107.aspx

or

http://www.codeproject.com/Tips/743507/Detecting-concurrency-issues-with-Entity-Framework

So, I have a table sql server like this:
IdProduct(int)
Name(varchar)
Price (decimal)
Version(timestamp)

I also have a .edmx file that reflects the database.
So, I set Version's property (inside edmx diagram) ConcurrencyMode = fixed.

Then, I opened my product on the windows form.

Manually I changed product's price (changing timestamp) in database.

Then click on savechanges() on winform, and it updated the record, although initial timestamp is changed...



code in class is this:

                                            try
                                            {
                                                _oc.SaveChanges();
                                            }
                                            catch (OptimisticConcurrencyException  ex)
                                            {
                                                return false;
                                            }           }



so, exception is never thrown!

I'm forget something?

thanks


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>