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(Type, Object, CancellationToken) Method

Asynchronously returns a persistent object that has the specified key property value.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public Task<object> GetObjectByKeyAsync(
    Type classType,
    object id,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function GetObjectByKeyAsync(
    classType As Type,
    id As Object,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)
public Task<object> GetObjectByKeyAsync(
    Type classType,
    object id,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function GetObjectByKeyAsync(
    classType As Type,
    id As Object,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)

Parameters

Name Type Description
classType Type

A Type object which represents the type of objects to search for.

id Object

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

cancellationToken CancellationToken

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

Parameters

Name Type Description
classType Type

A Type object which represents the type of objects to search for.

id Object

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

cancellationToken CancellationToken

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

Returns

Type Description
Task<Object>

A Task that returns a persistent object. This persistent object has the specified key property value.

Returns

Type Description
Task<Object>

A Task that returns a persistent object. This persistent object has the specified key property value.

Remarks

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

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

The GetObjectByKeyAsync method searches the memory for the object with the key property value. If such an object is found, it is not reloaded.

See Also