xpo-devexpress-dot-xpo-dot-persistentbase-81543d14.md
Indicates whether the object is currently being initialized.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
[MemberDesignTimeVisibility(false)]
[Browsable(false)]
public bool IsLoading { get; }
<MemberDesignTimeVisibility(False)>
<Browsable(False)>
Public ReadOnly Property IsLoading As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the object is currently being initialized; otherwise, false.
|
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:
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();
}
}
}
}
Public Class Order
Inherits XPObject
' ...
Private fTotal As Decimal
Public Property Total() As Decimal
Get
Return fTotal
End Get
Set(ByVal value As Decimal)
SetPropertyValue(NameOf(Total), fTotal, value)
If (Not IsLoading) AndAlso (Not IsSaving) Then
EnforceBusinessRule()
End If
End Set
End Property
End Class
See Also