Entity Framework, PostgreSQL, Optimistic Concurrency with hidden xmin column

前端 未结 1 581
南方客
南方客 2021-01-19 15:58

I\'m working with Entity Framework (Model First approach) against a PostgreSQL 9.1 database.

You probably all know that every table has a hidden column called

相关标签:
1条回答
  • 2021-01-19 16:15

    xmin is quite unlikely to go away any time soon, and can be used to implement a simple form of optimistic concurrency control for updates. Be careful in that internally it is an unsigned 32-bit number, so don't try to store it in a signed 32-bit field, or it is likely to work for a while and then break badly.

    As long as you map it to an appropriate data type, read it in up front, include it in the WHERE clause of your UPDATE and take appropriate action on a "not found" condition it is pretty straightforward.

    0 讨论(0)
提交回复
热议问题