Back to Devexpress

PersistenceValidationController.CustomGetAggregatedObjectsToValidate Event

expressappframework-devexpress-dot-expressapp-dot-validation-dot-persistencevalidationcontroller-7a02cc44.md

latest4.5 KB
Original Source

PersistenceValidationController.CustomGetAggregatedObjectsToValidate Event

Occurs when determining which aggregated objects should be validated.

Namespace : DevExpress.ExpressApp.Validation

Assembly : DevExpress.ExpressApp.Validation.v25.2.dll

NuGet Package : DevExpress.ExpressApp.Validation

Declaration

csharp
public event EventHandler<CustomGetAggregatedObjectsToValidateEventArgs> CustomGetAggregatedObjectsToValidate
vb
Public Event CustomGetAggregatedObjectsToValidate As EventHandler(Of CustomGetAggregatedObjectsToValidateEventArgs)

Event Data

The CustomGetAggregatedObjectsToValidate event's data class is CustomGetAggregatedObjectsToValidateEventArgs. The following properties provide information specific to this event:

PropertyDescription
AggregatedObjectsSpecifies the CustomGetAggregatedObjectsToValidateEventArgs.OwnerObject‘s aggregated objects to be validated.
HandledGets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
OwnerObjectSpecifies the object whose aggregated objects are about to be validated.

Remarks

Handle this event to manually specify the OwnerObject ‘s aggregated objects to be validated. By default, all aggregated objects are validated. To create the list of objects to be validated manually, add these objects to the AggregatedObjects list and set the Handled parameter to true.

Validation may take significant time when an object to be saved exposes a large collection of aggregated objects. By default, aggregated objects are considered to be an integral part of a master object, and thus, they should be validated together with the master object. The entire collection will be loaded in this instance. However, you can use the CustomGetAggregatedObjectsToValidate event to change this behavior and cancel validating the aggregated objects that are not updated. You can use the IObjectSpace.IsObjectToSave method to ensure that a certain object is not modified.

csharp
void CustomGetAggregatedObjectsToValidate(object sender, CustomGetAggregatedObjectsToValidateEventArgs e) {
    if (e.OwnerObject is Contact) {
        foreach (PhoneNumber number in ((Contact)e.OwnerObject).PhoneNumbers) {
            if (ObjectSpace.IsObjectToSave(number)) {
                e.AggregatedObjects.Add(number);
            }
        }
    }
    e.Handled = true;
}

Important

The drawback of this approach is that invalid aggregated objects that were added before the rule is introduced, or created in the database directly, will be skipped.

See the another example of using the CustomGetAggregatedObjectsToValidate event in the PersistenceValidationController class description.

See Also

PersistenceValidationController Class

PersistenceValidationController Members

DevExpress.ExpressApp.Validation Namespace