ComponentOne ADO.NET DataExtender
Working with C1DataViewSet / Row and Column Level Constraints
In This Topic
    Row and Column Level Constraints
    In This Topic

    C1DataView objects, constituting C1DataViewSet, allow you to define row and column level constraints declaratively, that is, you can specify a logical expression evaluating validity of row or column data as a property value of the corresponding row or column. In order to make these expressions powerful, ADO.NET DataExtender allows you to use syntax from any .NET Framework programming language available on your computer. Thus, you are able to write multi-line expression code which includes logical branches, loops and so on. When defining row and column level constraints, consider the following:

    Constraints can be defined both in C1DataViewSet (in C1DataView and constituting C1ViewColumn objects) and in the DataSetExtender (for table and column items), with the place of constraint definition influencing its semantics. Constraints defined in C1DataViewSet are evaluated only when changes are being made through a C1DataView row, or C1ViewRow object. The changes performed through the DataTable rows of an underlying dataset are not checked by these constraints. A constraint expression is based on a C1DataView row's values in this case, but not on values of base DataTable rows.

    In contrast, constraints defined in the DataSetExtender are evaluated when changes are made to underlying DataTable rows, directly or through C1DataView row (note that changes made to C1DataView row are reflected in underlying DataTable rows). In this case, the constraint expression uses values of a DataTable row (DataRow object).

    Any constraint expression is treated as the code of some class method returning a logical value and expressed in a specified .NET Framework programming language. Therefore, expression code must have a line which returns a value from the method (for example, RETURN statement for Visual Basic and C#).

    For row level constraint expressions the following class properties are accessible from the expression code:

    Example expression code in Visual Basic:

    RETURN row("UnitPrice") * row("Quantity") < 100

    For column level constraints you should treat expression as a method code of a class with the properties as follows:

    The new Value (of type System.Object) contains a new proposed column value.

    Example expression code in Visual Basic:

    RETURN newValue > 0

    Constraint expressions are defined through the ConstraintExpression property of corresponding classes (C1DataView, C1ViewRow, DataTableExtender and DataColumnExtender; DataTableExtender and DataColumnExtender define DataTable and DataColumn extended properties in the DataSetExtender) with the following nested properties:

    ConstraintExpression.Expression.Language defines the name of the .NET Framework programming language, whose syntax is used to define an expression.

    See Also