xpo-devexpress-dot-xpo-dot-session-dot-saveasync-x28-system-dot-object-system-dot-threading-dot-cancellationtoken-x29.md
Asynchronously saves the specified persistent object to a data store.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
public Task SaveAsync(
object theObject,
CancellationToken cancellationToken = default(CancellationToken)
)
Public Function SaveAsync(
theObject As Object,
cancellationToken As CancellationToken = Nothing
) As Task
| Name | Type | Description |
|---|---|---|
| theObject | Object |
An object which represents the persistent object to save.
|
| Name | Type | Default | Description |
|---|---|---|---|
| cancellationToken | CancellationToken | null |
A CancellationToken object that delivers a cancellation notice to the running operation.
|
| Type | Description |
|---|---|
| Task |
A Task that saves the specified persistent object to a data store.
|
Below is an example of using the SaveAsync method. Here, session is the Session instance.
Person personToUpdate = await session.FindObjectAsync<Person>(CriteriaOperator.Parse("Name='Michael Suyama'"));
personToUpdate.Birthday = new DateTime(1986, 10, 31);
await session.SaveAsync(personToUpdate);
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