Session.SaveAsync(Object, CancellationToken) Method
In This Article
Asynchronously saves the specified persistent object to a data store.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.2.dll
NuGet Package: DevExpress.Xpo
#Declaration
public Task SaveAsync(
object theObject,
CancellationToken cancellationToken = default(CancellationToken)
)
#Parameters
Name | Type | Description |
---|---|---|
the |
Object | An object which represents the persistent object to save. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellation |
Cancellation |
null | A Cancellation |
#Returns
Type | Description |
---|---|
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.
Person personToUpdate = await session.FindObjectAsync<Person>(CriteriaOperator.Parse("Name='Michael Suyama'"));
personToUpdate.Birthday = new DateTime(1986, 10, 31);
await session.SaveAsync(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