🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators IsDirty
This page was created by Peter on 2019-12-19. Last edited by Wikiadmin on 2026-07-29.

You can use isDirty in OCL to determine whether an object has changes that have not been saved, for example when an expression must react only to edited objects.

Syntax

self.isDirty

isDirty returns a Boolean value:

Result Meaning
true The object has changed since its last save.
false The object has not changed since its last save.

Example

Use self.isDirty when the expression concerns whether the current object has unsaved changes.

self.isDirty

For example, an expression using this operator evaluates to true after you change a value on the current object and before those changes are saved. After the object is saved, it evaluates to false until another change is made.

Check one attribute instead

isDirty checks the object. If you need to determine whether one specific class attribute has pending changes, use IsDirtyMember on that attribute.

Use with save actions

Save commits changes from a ViewModel to persistent storage. Use isDirty to test for changes before that save has occurred.

If you need to perform an action whenever an object is being saved, use OnUpdate. OnUpdate runs immediately before the object is saved; it is not a replacement for an expression that tests whether the object is currently dirty.

Related operators

IsNew answers a different question: whether the object has ever been saved to the database. An object can be new, while isDirty indicates whether it has changes since its last save.

See also