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+

Session.PreFetch(IEnumerable, XPMemberInfo, IEnumerable) Method

Enforces loading data for an associated collection.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public void PreFetch(
    IEnumerable objects,
    XPMemberInfo collectionInObjects,
    IEnumerable collectionsContent
)
Public Sub PreFetch(
    objects As IEnumerable,
    collectionInObjects As XPMemberInfo,
    collectionsContent As IEnumerable
)
public void PreFetch(
    IEnumerable objects,
    XPMemberInfo collectionInObjects,
    IEnumerable collectionsContent
)
Public Sub PreFetch(
    objects As IEnumerable,
    collectionInObjects As XPMemberInfo,
    collectionsContent As IEnumerable
)

Parameters

Name Type Description
objects IEnumerable

An IEnumerable list of parent objects.

collectionInObjects XPMemberInfo

An XPMemberInfo object that provides metadata information for an associated collection.

collectionsContent IEnumerable

An IEnumerable list of the collection's content. If the collectionInObjects data was previously loaded, you can avoid reloading it by passing the loaded data to the collectionsContent parameter. Note that if this parameter does not contain a part of the collection's content, this part will not be loaded from a database.

Parameters

Name Type Description
objects IEnumerable

An IEnumerable list of parent objects.

collectionInObjects XPMemberInfo

An XPMemberInfo object that provides metadata information for an associated collection.

collectionsContent IEnumerable

An IEnumerable list of the collection's content. If the collectionInObjects data was previously loaded, you can avoid reloading it by passing the loaded data to the collectionsContent parameter. Note that if this parameter does not contain a part of the collection's content, this part will not be loaded from a database.

Remarks

By default, data is loaded automatically when you access a nested collection for the first time. When the PreFetch method is called, all data for the specified collection is loaded at once. No additional SQL queries for this data will be performed later.

using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
// ...
XPCollection<Person> people = new XPCollection<Person>(session);
XPCollection<PhoneNumber> phoneNumbers = new XPCollection<PhoneNumber>(session);
XPMemberInfo phoneNumbersInfo = session.GetClassInfo(typeof(Person)).GetMember(nameof(PhoneNumbers));
session.PreFetch(people, phoneNumbersInfo, phoneNumbers);
See Also