The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

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.v19.1.dll

Declaration

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

Remarks

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 {
    [ExplicitLoading()]
    public Book theBook;
}
class Topic : XPObject {
    [ExplicitLoading()]
    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.

Inheritance

Object
Attribute
ExplicitLoadingAttribute

Implements

See Also