Skip to main content
All docs
V22.1
.NET Standard 2.0+

XAF0010: Set the DelayedAttribute.UpdateModifiedOnly property to True

  • 2 minutes to read

Severity: Warning

We recommend that you set the DelayedAttribute.UpdateModifiedOnly property to true when you use the DevExpress.Xpo.DelayedAttribute attribute. When the DelayedAttribute.UpdateModifiedOnly property to is set to true, only the modified values are included in the UPDATE statement. Otherwise, all properties (including delayed properties) are updated regardless of whether they were modified. This behavior reduces XPO performance. Refer to the following article for details: Delayed Loading.

This diagnostic works only for business classes derived from PersistentBase.

Examples

Invalid Code

using System;
using DevExpress.Xpo;

namespace TestApplication.Module.BusinessObjects {

    public class TestClass : XPObject {
        public TestClass(Session session): base(session) {}

        private XPDelayedProperty testProp1 = new XPDelayedProperty();
        private XPDelayedProperty testProp2 = new XPDelayedProperty();
        private XPDelayedProperty testProp3 = new XPDelayedProperty();

        // [Delayed(nameof(testProp1))] // Warning!
        public Byte[] TestProp1 {
            get { return (Byte[])testProp1.Value; }
            set { testProp1.Value = value; }
        }

        // 
        // [Delayed(nameof(testProp2), nameof(testProp2))] // Warning!
        public Byte[] TestProp2 {
            get { return (Byte[])testProp2.Value; }
            set { testProp2.Value = value; }
        }

        // [Delayed()] // Warning!
        public Byte[] TestProp3 {
            get { return (Byte[])testProp3.Value; }
            set { testProp3.Value = value; }
        }

        // [Delayed(false)] // Warning!
        public Byte[] TestProp4 {
            get { return GetDelayedPropertyValue<Byte[]>(nameof(TestProp4)); }
            set { SetDelayedPropertyValue<Byte[]>(nameof(TestProp4), value); }
        }

        // [Delayed] // Warning!
        public Byte[] TestProp5 {
            get { return GetDelayedPropertyValue<Byte[]>(nameof(TestProp5)); }
            set { SetDelayedPropertyValue<Byte[]>(nameof(TestProp5), value); }
        }
    }
}

Valid Code

using System;
using DevExpress.Xpo;

namespace TestApplication.Module.BusinessObjects {

    public class TestClass : XPObject {
        public TestClass(Session session): base(session) {} 

        private XPDelayedProperty testProp1 = new XPDelayedProperty();
        private XPDelayedProperty testProp2 = new XPDelayedProperty();
        private XPDelayedProperty testProp3 = new XPDelayedProperty();

        // This attribute usage meets the recommendations
        [Delayed(nameof(testProp1), true)]
        public Byte[] TestProp1 {
            get { return (Byte[])testProp1.Value; }
            set { testProp1.Value = value; }
        }

        // This attribute usage meets the recommendations
        [Delayed(nameof(testProp2), nameof(testProp2), true)]
        public Byte[] TestProp2 {
            get { return (Byte[])testProp2.Value; }
            set { testProp2.Value = value; }
        }

        // This attribute usage meets the recommendations
        [Delayed(true)]
        public Byte[] TestProp3 {
            get { return (Byte[])testProp3.Value; }
            set { testProp3.Value = value; }
        }
}

How to Fix

Set the DelayedAttribute.UpdateModifiedOnly property to true when you use the DevExpress.Xpo.DelayedAttribute attribute.