A newer version of this page is available. Switch to the current version.

ExplicitLoadingAttribute Class

Specifies that the information used to retrieve persistent objects that are referenced by the current property, is included in a query used to load this property.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v18.2.dll


[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class ExplicitLoadingAttribute :
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, Inherited:=True)>
Public NotInheritable Class ExplicitLoadingAttribute
    Inherits Attribute


By design, when a property referencing a persistent object is loaded, XPO generates and executes several queries to retrieve this property. One retrieves a reference to the persistent object and the other for each property of the persistent object. It is a recursive process, since the retrieved property in its turn might reference another persistent object. To improve performance by assembling the intermediate queries into one query which is executed only once, use the ExplicitLoadingAttribute. The reference depth of the objects retrieved is controlled by the optional ExplicitLoadingAttribute.Depth parameter. Its default value is 1.

Let us consider a simple example.

class Book : XPObject {
    public string Name = "";
class Article : XPObject {
    public Book theBook;
class Topic : XPObject {
    public Article theArticle;
class Category : XPObject {
    public Topic theTopic;

By marking theArticle and theBook properties with the ExplicitLoadingAttribute we have specified that the information about the Topic and Article classes' properties will be retrieved in one query if the owning class is not deeper than 1 level from the root Category class. Since the Topic class has theArticle property of the Article type marked with the ExplicitLoadingAttribute and the Topic class is one level deep from the root Category class, the information to retrieve its property value will be included in the query. The Article class has theBook property of the Book type marked with the ExplicitLoadingAttribute. In this business model the Book class is two levels deeper than the root Category class, thus information for theBook property will not be included in the query, although this information will be used to generate a new query. If you specify ExplicitLoading(2) attribute for theBook property it will be enough to retrieve all the properties in the Category's class.


See Also