Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

XAF0023: Do not implement IObjectSpaceLink in the XPO classes

Severity: Warning

Do not implement the IObjectSpaceLink interface in an XPO class. Instead, use the Session property to query or modify data inside a persistent class. Use IObjectSpace only in XAF Controllers.

#Examples

#Invalid Code

using DevExpress.Xpo;

namespace TestApplication.Module.BusinessObjects {
    // Do not implement IObjectSpaceLink in the XPO classes
    public class BaseObject1 : BaseObject, IObjectSpaceLink { // Warning
        public BaseObject1(Session session) : base(session) {}

        public IObjectSpace ObjectSpace { get; set; }
        public bool IsDirty { 
            get { 
                // Use ObjectSpace only in XAF Controllers
                return ObjectSpace.IsObjectToSave(this) || ObjectSpace.IsNewObject(this); 
            } 
        }
    }
}

#Valid Code

C#
using DevExpress.Xpo;

namespace TestApplication.Module.BusinessObjects {
    public class BaseObject1 : BaseObject {
        public BaseObject1(Session session) : base(session) {}

        public bool IsDirty { 
            get { 
                // This code meets the requirements
                return Session.IsObjectToSave(this) || Session.IsNewObject(this); 
            } 
        }
    }
}