Skip to main content
.NET Standard 2.0+

PersistentBase.IsLoading Property

Indicates whether the object is currently being initialized.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.2.dll

Declaration

[MemberDesignTimeVisibility(false)]
[Browsable(false)]
public bool IsLoading { get; }

Property Value

Type Description
Boolean

true if the object is currently being initialized; otherwise, false.

Remarks

While XPO is modifying an object, the object is considered to be initialized. While an object is in this state, you shouldn’t access its properties or change the property values. The object is considered to be initialized in the following cases:

  • The object is being loaded from a data source.
  • The parent session (or unit of work) gets the changes made within its nested session.
  • Data editing has been canceled.
  • The optimistic concurrency and autogenerated key(s) are being processed.

If you need to enforce a business rule in a persistent class’ property setter or getter, ensure that the object is not currently being initialized. The following code snippet illustrates this.

public class Order : XPObject {
    // ...
    private decimal fTotal;
    public decimal Total {
        get { return fTotal; }
        set {
            SetPropertyValue(nameof(Total), ref fTotal, value);
            if(!IsLoading && !IsSaving) {
                EnforceBusinessRule();            
            }
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the IsLoading property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also