expressappframework-403726-debugging-testing-and-error-handling-code-diagnostics-xaf0011.md
Severity: Error
XPO requires that every delayed property is decorated with the DevExpress.Xpo.DelayedAttribute attribute and meets one of these requirements:
GetDelayedPropertyValue<T>() and SetDelayedPropertyValue<T>() methods in its getter and setter, respectively.or
Refer to the following article for details: Delayed Loading
This diagnostic works only for business classes derived from PersistentBase.
using DevExpress.Xpo;
namespace TestApplication.Module.BusinessObjects {
public class TestClass : XPObject {
public TestClass(Session session): base(session) {}
// The delayed property is not implemented correctly.
// [Delayed(true)] // Error
// public int TestProperty1 { get; set; }
private int testProperty2;
// The delayed property is not implemented correctly.
// [Delayed(true)] // Error
// public int TestProperty2 {
// get { return testProperty2; }
// set { SetPropertyValue(nameof(TestProperty2), ref testProperty2, value); }
// }
}
}
using DevExpress.Xpo;
using System;
namespace TestApplication.Module.BusinessObjects {
public class TestClass : XPObject {
public TestClass(Session session): base(session) {}
private XPDelayedProperty testProp1 = new XPDelayedProperty();
// The property that meets the requirements
[Delayed(nameof(testProp1), true)]
public Byte[] TestProp1 {
get { return (Byte[])testProp1.Value; }
set { testProp1.Value = value; }
}
// The property that meets the requirements
[Delayed(true)]
public Byte[] Image {
get { return GetDelayedPropertyValue<Byte[]>(nameof(Image)); }
set { SetDelayedPropertyValue<Byte[]>(nameof(Image), value); }
}
}
}
Ensure a delayed property uses the GetDelayedPropertyValue<T>() and SetDelayedPropertyValue<T>() methods in its getter and setter, respectively.