I am a new user of dotconnect and was curious if updatable views are supported?
I have not been able to get them to update to database using the datacontext.(gridview -> bindingsource -> datacontext.SubmitChanges) in a simple test project. The views do update to database as expected when tested in the GUI of DBeaver and DbForge as well as in SQL. I tried a simple view which should be automatic and a view with a couple joins. (For the more complex view I implemented a function using INSERT INTO ... ON CONFLICT and triggers using INSTEAD OF for the upserts and deletes.)
postgres updatable view
Re: postgres updatable view
I think I solved the issue myself. The problem seems to occur because the Linq-To-SQL entity automatically generated by a View does not have an Entity Key defined by default -- unlike a Table.
It is curious that Visual Studio did not produce an error when I tried an upsert on the View. I would have expected to see a "System.InvalidOperationException: Can't perform Create, Update or Delete operations on ... does not have identity members" error.
The solution is to open the DataContext diagram for the View in Entity Developer, select the key, go to Properties and toggle Entity Key to True. Now, if the upsert on the view works in dbForge, it should then work in c# .net.
It is curious that Visual Studio did not produce an error when I tried an upsert on the View. I would have expected to see a "System.InvalidOperationException: Can't perform Create, Update or Delete operations on ... does not have identity members" error.
The solution is to open the DataContext diagram for the View in Entity Developer, select the key, go to Properties and toggle Entity Key to True. Now, if the upsert on the view works in dbForge, it should then work in c# .net.
Re: postgres updatable view
Thank you for sharing your experience.
JIC: you can use the dbMonitor tool for tracing database activity for debug purpose.
JIC: you can use the dbMonitor tool for tracing database activity for debug purpose.