Rules |
[This is preliminary documentation and is subject to change.]
This topic contains the following sections:
Rules are validation functions. The message the function returns can be attached to cells.
Rules work like computed columns. They are defined on a table and managing results per row. Result of a rule calculation is a fault. The fault can be attached to cells using parameters "Tag Cells" setting.
A rule function returns an instance of BcfFaultMessage or null. It is good practice to create a custom fault-message class. To cause BCF-Editor validate rule-functions returns an instance of this class specify it in Project-Settings: DataSetSetup as "FaultMessage Base Type".
Rule function examples:
At runtime all faults are accessible using BcfDataSetFaults. To get the fault of a specific rule and row use myDataSet.Faults.TryGetFault(myRow, myRule).
Extending BcfFaultMessage is common practice (see: Business Model - Main Objects).
Rule parameters are equal to function parameters except the "Tag Cells" setting (see Parameter: Settings/Tag Cells and TagCells).
If TagCells is true the fault will be added to referenced cells fault collection (the cells are tagged with fault). To access all faults of a cell use BcfRowGetFaults or BcfCellFaults.
For example if all three parameters of sample rule function (birthDate > hireDate and string.IsNullOrWhiteSpace(reason)) ? new BcfFaultMessage("Really? Enter a reason!") : null have set "Tag Cells"; the three cells are tagged with the same fault.