.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Session.PreFetchAsync(XPClassInfo, IEnumerable, CancellationToken, String[]) Method

Asynchronously forces associated collection data loading and delayed property loading for specified parent objects.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v20.1.dll


public Task PreFetchAsync(
    XPClassInfo classInfo,
    IEnumerable objects,
    CancellationToken cancellationToken,
    params string[] propertyPaths
Public Function PreFetchAsync(
    classInfo As XPClassInfo,
    objects As IEnumerable,
    cancellationToken As CancellationToken,
    ParamArray propertyPaths As String()
) As Task


Name Type Description
classInfo XPClassInfo

An XPClassInfo object that contains metadata information. This data specifies the parent object that needs associated collection data loading and delayed property loading.

objects IEnumerable

An IEnumerable list of parent objects.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

propertyPaths String[]

An array of strings that are the collection property and delayed property names, or property paths (e.g, "ChildCollection.AnotherChildCollection").


Type Description

A Task that forces associated collection data loading and delayed property loading for specified parent objects.


By default, data is loaded automatically when you access a nested collection or delayed property for the first time. When the PreFetchAsync method is called, all associated collection data and delayed properties are loaded at once for specified parent objects. No additional SQL queries for this data will be will be performed later.

using System.Threading;
using DevExpress.Xpo;
// ...
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
CancellationToken cancellationToken = cancellationTokenSource.Token;
XPCollection<Person> people = new XPCollection<Person>(session);
await session.PreFetchAsync(session.GetClassInfo<Person>(), people, cancellationToken, nameof(PhoneNumbers));
See Also