I can’t imagine that this is a new problem, but I’m not finding any answers regarding this issue.
Using WCF and VS-generated data objects for a C# project, this issue centers around the SetEntitySetAccessRule() method which (as you know) sets the access permissions for each table in the db. Every table that requires interaction must call this method within the InitializeService() method that is called per WCF database implementation. These rule sets are then published to the web server (hosted by MS 2008 R2 and IIS 7.5) and that’s our portal.
Let’s say we have two tables: Orders and Customers. Orders can be set to write-only, and Customers can be set to read-only. This model works fine, until… You want to add a row to the customer; the read-only permissions set in SetEntitySetAccessRule() will block any attempt to write to the Customers table (including when using the VS interface.)
Is there any way of making the permissions for a table declared within InitializeService some sort of variable dependent? Or do we need to allow the Customers table to be writeable for the basic fact that we need to modify the table on occasion?
I believe you can set the rights to All and then apply a change interceptor to the tables that need special handling. There you can cancel the request based on your business rules.
You can see more information at http://mattfrear.com/2011/02/25/inserting-odata/