I am using.NET Framework 4.6.1, WinForms, PostgreSQL 6.4beta4 and Npgsql and ADO.NET.
My current application is a multi-user-application where all users connect to the same database.
Data gets bound to the controls by using DataTable, BindingSource, and BindingNavigator.
I want to avoid that two users can edit a DataRow at the same time. Because I want to implement this on a more general approach I was thinking about creating a DataTable descendant and add the property LockMode (None, Row, Table).
I found out that you can use the ColumnChanged event in combination with RowState to detect changes on the data.
I now know whether the user is inserting a new value, editing (RowState = modified) an existing one or just looks (RowState = Unchanged) at the record.
Therefore I am looking for a solution to lock the DataRow once a user starts editing it. In the application, i want to display a message once a user navigates (by using the Bindingnavigator or programmatically) to a locked record.
Most solutions I found target MySql Server like this one: How to perform a row lock? or TransactionScope locking table and IsolationLevel.
However I am looking for a PostgreSQL solution, so even articles on this topic from MS (https://msdn.microsoft.com/en-us/library/system.transactions.transactionscope(v=vs.110).aspx) cannot be used here.
I would appreciate if someone with experience in PostgreSQL and ADO.NET could help me out here. Thanks.