Click or drag to resize

ConnectionUpdatePersistentObjectAsync Method

Updates a persistent object from the data store as an asynchronous operation.

Namespace:  Obujekutoru
Assembly:  obujekutoru (in obujekutoru.dll) Version: 1.2.0.35246
Syntax
public Task UpdatePersistentObjectAsync(
	PersistentObject persistentObject
)

Parameters

persistentObject
Type: ObujekutoruPersistentObject
The persistent object to be updated.

Return Value

Type: Task
The task object representing the asynchronous operation.
Exceptions
ExceptionCondition
ArgumentNullExceptionThe persistent object is null.
InvalidOperationException The connection has been disposed of, the persistent object is new, the persistent object is not dirty.
Examples
using System;
using System.Collections;
using System.Collections.Generic;

using Obujekutoru;

namespace ObujekutoruExamples.ConnectionUpdateExample
{
  ...

    internal class AsyncUpdateClass
    {
        public async void UpdateAsyncMethod()
        {
            String dataFolderPath = @"C:\Temp\ObujekutoruData";
            EncryptionType encryptionType = EncryptionType.DESEncryption;
            String encryptionKey = "A proavo habui, quod publicos litterarum ludos non frequentavi, et domi bonis praeceptoribus usus...";

            List<PersistentObjectE> persistentObjects;

            using (Connection connection = new Connection(dataFolderPath, encryptionType, encryptionKey, true))
            {
                PersistentObjectE persistentObjectE1 = new PersistentObjectE("persistent object E1", 1);
                PersistentObjectE persistentObjectE2 = new PersistentObjectE("persistent object E2", 2);
                PersistentObjectE persistentObjectE3 = new PersistentObjectE("persistent object E3", 3);

                await connection.InsertPersistentObjectAsync(persistentObjectE1);
                await connection.InsertPersistentObjectAsync(persistentObjectE2);
                await connection.InsertPersistentObjectAsync(persistentObjectE3);

                persistentObjects = await connection.SelectPersistentObjectAsync<PersistentObjectE>(
                    PersistentObjectFieldFilterCollection.With(
                        "persistentObjectValue",
                        PersistentObjectFieldFilterOperator.Equal,
                        2),
                    PersistentObjectFieldSorterCollection.Empty(),
                    1, Int32.MaxValue);

                PersistentObjectE persistentObjectToUpdate = persistentObjects[0];

                persistentObjectToUpdate.PersistentObjectName = "persistent object E2 updated!";

                await connection.UpdatePersistentObjectAsync(persistentObjectToUpdate);

                persistentObjects = await connection.SelectPersistentObjectAsync<PersistentObjectE>(
                    PersistentObjectFieldFilterCollection.With(
                        "persistentObjectValue",
                        PersistentObjectFieldFilterOperator.Equal,
                        2),
                    PersistentObjectFieldSorterCollection.Empty(),
                    1, Int32.MaxValue);

                Console.WriteLine("persistentObjects[0] = {0}", persistentObjects[0].PersistentObjectName);
            }
        }
    }

  ...
}
See Also