Click or drag to resize

ConnectionInsertPersistentObject Method

Inserts a persistent object in the data store.

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

Parameters

persistentObject
Type: ObujekutoruPersistentObject
The persistent object to be inserted.
Exceptions
ExceptionCondition
ArgumentNullExceptionThe persistent object is null.
InvalidOperationException The connection has been disposed of, the persistent object is old.
Examples
using System;
using System.Collections;
using System.Collections.Generic;

using Obujekutoru;

namespace ObujekutoruExamples.ConnectionInsertExample
{
    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...";

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

                connection.InsertPersistentObject(persistentObjectE1);
                connection.InsertPersistentObject(persistentObjectE2);
                connection.InsertPersistentObject(persistentObjectE3);

                List<PersistentObjectE> persistentObjects = connection.SelectPersistentObject<PersistentObjectE>(
                    PersistentObjectFieldFilterCollection.Empty(),
                    PersistentObjectFieldSorterCollection.With(
                        "persistentObjectName", PersistentObjectFieldSortOperator.Ascending),
                    1, Int32.MaxValue);

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

    [PersistentObject("PersistentObjectE")]
    internal class PersistentObjectE : PersistentObject
    {
        [PersistentObjectField("persistentObjectName", true)]
        private String _persistentObjectName;

        public PersistentObjectE()
        { }
        public PersistentObjectE(String persistentObjectName)
        {
            _persistentObjectName = persistentObjectName;
        }

        public String PersistentObjectName
        {
            get { return _persistentObjectName; }
            set
            {
                _persistentObjectName = value;

                OnObjectUpdated();
            }
        }
    }
}
See Also