| ConnectionUpdatePersistentObject Method |
Updates a persistent object from the data store.
Namespace: ObujekutoruAssembly: obujekutoru (in obujekutoru.dll) Version: 1.0.0.19089 (1.0.0.*)
Syntax public void UpdatePersistentObject(
PersistentObject persistentObject
)
Public Sub UpdatePersistentObject (
persistentObject As PersistentObject
)
public:
void UpdatePersistentObject(
PersistentObject^ persistentObject
)
member UpdatePersistentObject :
persistentObject : PersistentObject -> unit
Parameters
- persistentObject
- Type: ObujekutoruPersistentObject
The persistent object to be updated.
Exceptions Examples using System;
using System.Collections;
using System.Collections.Generic;
using Obujekutoru;
namespace ObujekutoruExamples.ConnectionUpdateExample
{
class Program
{
static void Main(string[] args)
{
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<PersistentObject> 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);
connection.InsertPersistentObject(persistentObjectE1);
connection.InsertPersistentObject(persistentObjectE2);
connection.InsertPersistentObject(persistentObjectE3);
persistentObjects = connection.SelectPersistentObject(
typeof(PersistentObjectE),
PersistentObjectFieldFilterCollection.Empty().And(
"persistentObjectValue",
PersistentObjectFieldFilterOperator.Equal,
2),
PersistentObjectFieldSorterCollection.Empty(),
1, Int32.MaxValue);
PersistentObjectE persistentObjectToUpdate = (PersistentObjectE)persistentObjects[0];
persistentObjectToUpdate.PersistentObjectName = "persistent object E2 updated!";
connection.UpdatePersistentObject(persistentObjectToUpdate);
persistentObjects = connection.SelectPersistentObject(
typeof(PersistentObjectE),
PersistentObjectFieldFilterCollection.Empty().And(
"persistentObjectValue",
PersistentObjectFieldFilterOperator.Equal,
2),
PersistentObjectFieldSorterCollection.Empty(),
1, Int32.MaxValue);
Console.WriteLine("persistentObjects[0] = {0}", (persistentObjects[0] as PersistentObjectE).PersistentObjectName);
}
}
}
[PersistentObject("PersistentObjectE")]
internal class PersistentObjectE : PersistentObject
{
[PersistentObjectField("persistentObjectName", true)]
private String _persistentObjectName;
[PersistentObjectField("persistentObjectValue", true)]
private Int32 _persistentObjectValue;
public PersistentObjectE()
{ }
public PersistentObjectE(String persistentObjectName, Int32 persistentObjectValue)
{
_persistentObjectName = persistentObjectName;
_persistentObjectValue = persistentObjectValue;
}
public String PersistentObjectName
{
get { return _persistentObjectName; }
set
{
_persistentObjectName = value;
_isDirty = true;
_updated = DateTime.UtcNow;
}
}
public Int32 PersistentObjectValue
{
get { return _persistentObjectValue; }
set
{
_persistentObjectValue = value;
_isDirty = true;
_updated = DateTime.UtcNow;
}
}
}
}
See Also