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.GetObjectByKeyAsync<ClassType>(Object, Boolean, CancellationToken) Method

Asynchronously returns a persistent object that has the specified key property value. The persistent object's type is set by the generic type parameter.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public Task<ClassType> GetObjectByKeyAsync<ClassType>(
    object id,
    bool alwaysGetFromDataStore,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function GetObjectByKeyAsync(Of ClassType)(
    id As Object,
    alwaysGetFromDataStore As Boolean,
    cancellationToken As CancellationToken = Nothing
) As Task(Of ClassType)
public Task<ClassType> GetObjectByKeyAsync<ClassType>(
    object id,
    bool alwaysGetFromDataStore,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function GetObjectByKeyAsync(Of ClassType)(
    id As Object,
    alwaysGetFromDataStore As Boolean,
    cancellationToken As CancellationToken = Nothing
) As Task(Of ClassType)

Parameters

Name Type Description
id Object

An object that represents the persistent object's key property value.

alwaysGetFromDataStore Boolean

true, to always reload the persistent object from storage even if it is found in memory; otherwise, false.

cancellationToken CancellationToken

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

Parameters

Name Type Description
id Object

An object that represents the persistent object's key property value.

alwaysGetFromDataStore Boolean

true, to always reload the persistent object from storage even if it is found in memory; otherwise, false.

cancellationToken CancellationToken

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

Returns

Type Description
Task<ClassType>

A Task that returns a persistent object from a data store. This persistent object has the specified key property value and a type specified by the generic type parameter.

Returns

Type Description
Task<ClassType>

A Task that returns a persistent object from a data store. This persistent object has the specified key property value and a type specified by the generic type parameter.

Type Parameters

Name Description
ClassType

Type Parameters

Name Description
ClassType

Remarks

Below is an example of using the GetObjectByKeyAsync<ClassType> method. Here, the session is the Session instance.

using System.Threading;
using DevExpress.Xpo;
// ...
CancellationTokenSource source = new CancellationTokenSource();
CancellationToken cancellationToken = source.Token;
Person personToDelete = await session.GetObjectByKeyAsync<Person>(152, true, cancellationToken);
session.Delete(personToDelete);

The GetObjectByKeyAsync<ClassType> method searches the memory for the object with the specified key property value. If such an object is found, it is not reloaded. To get the up-to-date object from the data store, the alwaysGetFromDataStore parameter must be set to true.

See Also