-
In the Csla 6.2.2 Samples, PersonEdit class in 'BlazorExample', Insert and Update, in addition to Fetch, specify BypassPropertyChecks. Is this an error, or is this because the property checks are now done elsewhere? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
It is fairly normal to use BypassPropertyChecks to avoid doing multiple rule executions during data access operations. It is more efficient to do the validation only once, in the situation that any rules are dependent upon multiple properties. If you want to, you can optionally call CheckRules after the properties have been loaded to update the status of all of the validation rules. That runs all of the rules at once, only once. Example: Rule1 is dependent upon Property1 and Property2. If you do not use BypassPropertyChecks then Rule1 runs twice, once as Property1 is set and one as Property2 is set. Using BypassPropertyChecks and CheckRules ensures that Rule1 runs only once. There are two schools of thought as to whether to validate during a fetch operation. Generally, Rocky writes the code samples based on the belief that the data could not have made it into the database if the data were invalid. I tend to run the rules after a fetch anyway, to cater for the system changing over time - new rules might be added to the system after the data was first written to the database. |
Beta Was this translation helpful? Give feedback.
-
You should also keep in mind that BypassPropertyChecks will also bypass authz rules that could possibly deny read of property value. So use BypassPropertyCheks to make sure you can read all the properties by using the property getter (=> GetProperty) |
Beta Was this translation helpful? Give feedback.
-
I would not bypassPropertyChecks on insert and updates. I use it to bypass on reads only when I'm formatting my objects from the ORM. |
Beta Was this translation helpful? Give feedback.
-
To make sure that your code can call BO.Property and get the actual value in the Insert/Update method.
Will eventually end up here:
So if the user does not have read permission you may get default value for the type rather than the actual value. |
Beta Was this translation helpful? Give feedback.
To make sure that your code can call BO.Property and get the actual value in the Insert/Update method.
Will eventually end up here: