Back to Devexpress

Session.SaveAsync(Object, CancellationToken) Method

xpo-devexpress-dot-xpo-dot-session-dot-saveasync-x28-system-dot-object-system-dot-threading-dot-cancellationtoken-x29.md

latest2.8 KB
Original Source

Session.SaveAsync(Object, CancellationToken) Method

Asynchronously saves the specified persistent object to a data store.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public Task SaveAsync(
    object theObject,
    CancellationToken cancellationToken = default(CancellationToken)
)
vb
Public Function SaveAsync(
    theObject As Object,
    cancellationToken As CancellationToken = Nothing
) As Task

Parameters

NameTypeDescription
theObjectObject

An object which represents the persistent object to save.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

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

|

Returns

TypeDescription
Task

A Task that saves the specified persistent object to a data store.

|

Remarks

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

csharp
Person personToUpdate = await session.FindObjectAsync<Person>(CriteriaOperator.Parse("Name='Michael Suyama'"));
personToUpdate.Birthday = new DateTime(1986, 10, 31);
await session.SaveAsync(personToUpdate);
vb
Dim personToUpdate As Person = Await session.FindObjectAsync(Of Person)(CriteriaOperator.Parse("Name='Michael Suyama'"))
personToUpdate.Birthday = New Date(1986, 10, 31)
Await session.Save(personToUpdate)

The SaveAsync method also saves all the referenced objects that are aggregated (see the AggregatedAttribute topic for information) and any referenced newly created non-aggregated objects that don’t yet exist in the data store.

See Also

Session Class

Session Members

DevExpress.Xpo Namespace