If a table or a view is mapped where the user does not have the rights to change data, it is not helpful that the exception is thrown during commit. Sometimes it is hard to find the place where the write access is done. Those exceptions can now be enforced to be thrown during the write operation itself.
The attribute can be set at class level but the wizard does not contain it. In the Q2 release you have to do it by hand, the Q2 Sp1 will contain the UI.
The settings on class level are:
To do this setting just open the related app.config file, search for the specific class and add behavior="readonly" to the class node:
<class name="Person" behavior="readonly"> |
</class> |
Let’s have a look at field level. Read only field must be handled more careful. If you set a field to readonly it will not be included into the insert statement. It must be possible to insert the table data without providing data for the underlying column. The setting can be used for fields that are calculated on the server. If you read the field in the next transaction the fields content is fetched from the server and you see the calculated value.
The settings on field level are:
To do this setting just open the related app.config file, search for the specific class and field and add behavior="readonly" to the field node:
<class name="Person"> |
<field name="name" behavior="readonly"> |
</field> |
</class> |
This is not working for primary key fields, there you have to use the
<extension key="db-key-generator" value="AUTOINC" /> |
on class level.