コード例 #1
0
        public static void populateWithDebugData(iSerializerSession sess)
        {
            var curTest = sess.Cursor <FiltersTest>();

            using (var trans = sess.BeginTransaction())
            {
                curTest.AddRange(debugData());
                trans.Commit();
            }
        }
コード例 #2
0
        static bool create(iSerializerSession sess)
        {
            Record r = askRecord();

            if (null == r)
            {
                return(false);
            }
            sess.Cursor <Record>().Add(r);
            return(true);
        }
コード例 #3
0
        /// <summary>Construct, adding all records from the specified table.</summary>
        /// <param name="sess"></param>
        public EditableObjectList(iSerializerSession sess)
        {
            m_table = sess.Cursor <tRow>();
            var bl = new BookmarkedRecordset <tRow>(m_table);

            foreach (var r in bl.all())
            {
                base.Add(r);
            }

            base.AllowNew = true;
        }
コード例 #4
0
        /// <summary>Construct the schema updater.</summary>
        /// <param name="sess"></param>
        public DatabaseSchemaUpdater(iSerializerSession sess)
        {
            this.session = sess;
            sess.AddType(typeof(DatabaseSchema));

            var cursor = sess.Cursor <DatabaseSchema>();

            if (cursor.TryMoveFirst())
            {
                this.DatabaseSchemaVersion = cursor.getCurrent().schemaVersion;
            }
            else
            {
                this.DatabaseSchemaVersion = 0;
            }
        }
コード例 #5
0
        static void PopulateDemoDatabase(iSerializerSession sess)
        {
            Person[] personsTest = new Person[]
            {
                new Person(Person.eSex.Female, "Jenifer Smith", new string[0]),
                new Person(Person.eSex.Male, "Konstantin", new string[] { "+7 926 139 63 18" }),
                new Person(Person.eSex.Male, "John Smith", new string[] { "+1 800 123 4567", "+1 800 123 4568" }),
                new Person(Person.eSex.Female, "Mary Jane", new string[] { "555-1212" }),
                new Person(Person.eSex.Other, "Microsoft", new string[] { "+1 800 642 7676", "1-800-892-5234" }),
            };

            Cursor <Person> curPerson = sess.Cursor <Person>();

            using (var trans = sess.BeginTransaction())
            {
                curPerson.AddRange(personsTest);
                trans.Commit();
            }
        }
コード例 #6
0
        /// <summary>Submits schema changes to the database in a single transaction.</summary>
        /// <remarks>This call will also flush the list of the pending actions, so you can upgrade sequentially, i.e. upgrade from ver.1 to ver.2, Execute(), upgrade from ver.2 to ver.3, Execute().</remarks>
        public void Execute()
        {
            using (var trans = this.session.BeginTransaction())
            {
                this.actUpgrade();

                var cursor = session.Cursor <DatabaseSchema>();
                if (cursor.TryMoveFirst())
                {
                    DatabaseSchema schema = cursor.getCurrent();
                    if (this.DatabaseSchemaVersion < schema.schemaVersion)
                    {
                        throw new SerializationException("Schema version number must not decrement");
                    }
                    if (this.DatabaseSchemaVersion > schema.schemaVersion)
                    {
                        schema.schemaVersion = this.DatabaseSchemaVersion;
                        cursor.Update(schema);
                    }
                }
                else
                {
                    if (this.DatabaseSchemaVersion <= 0)
                    {
                        throw new SerializationException("Schema version number must be positive");
                    }
                    DatabaseSchema schema = new DatabaseSchema();
                    schema.schemaVersion = this.DatabaseSchemaVersion;
                    cursor.Add(schema);
                }
                trans.Commit();
            }

            // Since the transaction was committed successfully, we clear the actions so that Updater can be reused several times.
            this.actUpgrade = () => { };
        }