Пример #1
0
 public ArrayOfWeakrefs(SessionBase session)
 {
   anArrayOfWeakRefs = new WeakIOptimizedPersistableReference<Person>[10];
   Person p = new Person();
   p.Persist(session, p);
   anArrayOfWeakRefs[0] = new  WeakIOptimizedPersistableReference<Person>(p);
   p = new Person();
   p.Persist(session, p);
   anArrayOfWeakRefs[1] = new  WeakIOptimizedPersistableReference<Person>(p);
   p = new Person();
   p.Persist(session, p);
   anArrayOfWeakRefs[2] = new  WeakIOptimizedPersistableReference<Person>(p);
   p = new Person();
   p.Persist(session, p);
   anArrayOfWeakRefs[3] = new  WeakIOptimizedPersistableReference<Person>(p);
 }
Пример #2
0
        public ArrayOfWeakrefs(SessionBase session)
        {
            anArrayOfWeakRefs = new WeakIOptimizedPersistableReference <Person> [10];
            Person p = new Person();

            p.Persist(session, p);
            anArrayOfWeakRefs[0] = new  WeakIOptimizedPersistableReference <Person>(p);
            p = new Person();
            p.Persist(session, p);
            anArrayOfWeakRefs[1] = new  WeakIOptimizedPersistableReference <Person>(p);
            p = new Person();
            p.Persist(session, p);
            anArrayOfWeakRefs[2] = new  WeakIOptimizedPersistableReference <Person>(p);
            p = new Person();
            p.Persist(session, p);
            anArrayOfWeakRefs[3] = new  WeakIOptimizedPersistableReference <Person>(p);
        }
Пример #3
0
 public void bCreateDefaultCompareIntKeyPersonValue(int number)
 {
   Oid id;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Placement place = new Placement((UInt32)number, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
     Placement personPlace = new Placement((UInt32)number + 1, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
     session.BeginUpdate();
     BTreeMap<int, Person> bTree = new BTreeMap<int, Person>(null, session);
     bTree.Persist(place, session);
     id = bTree.Oid;
     Person person;
     for (int i = 0; i < number; i++)
     {
       person = new Person();
       person.Persist(personPlace, session);
       bTree.Add(i, person);
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginRead();
     BTreeMap<int, Person> bTree = (BTreeMap<int, Person>)session.Open(id);
     int count = 0;
     int prior = 0;
     foreach (KeyValuePair<int, Person> pair in bTree)
     {
       count++;
       Assert.True(pair.Key == prior++);
       Assert.True(pair.Value != null);
     }
     Assert.True(number == count);
     session.Commit();
   }
 }
Пример #4
0
        public void SimpleApiServer()
        {
            long   ssn = 555555;
            UInt16 age = 1;

            VelocityDbSchema.Person mats;
            Placement place;

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                // skip delete database since it invalidates indices

                session.BeginUpdate();
                Database db = session.OpenDatabase(10, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                session.Commit();
                session.BeginUpdate();
                place = new Placement(10, 2, 1, 1, 10);
                DateTime birthday = new DateTime(1960, 6, 13);
                mats = new Man("Mats", "Persson", age++, ssn++, birthday);
                mats.Persist(place, session);
                session.Commit();
                session.ClearServerCache();
            }
            UInt64 mOid1 = Oid.Encode(10, 2, 1);

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                UInt32 dbNum = Oid.DatabaseNumber(mOid1);
                mats = (VelocityDbSchema.Person)session.Open(mOid1);
                Woman kinga = null;
                mats = new Man("Mats", "Persson", age++, ssn++, new DateTime(1960, 6, 13));
                Cat cat = new Cat("Boze", 8);
                mats.m_pets.Add(cat);
                Bird bird = new Bird("Pippi", 1);
                cat.friends.Add(bird);
                mats.Persist(place, session);
                kinga = new Woman("Kinga", "Persson", age, ssn, mats, mats);
                kinga.Persist(place, session);
                VelocityDbSchema.Person robin = new VelocityDbSchema.Person("Robin", "Persson", 13, 1, mats, null);
                robin.Persist(place, session);
                mOid1 = mats.Id;
                mats  = null;
                mats  = (VelocityDbSchema.Person)session.Open(mOid1);
                session.Commit();
                session.ClearServerCache();
            }

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                mats = (VelocityDbSchema.Person)session.Open(mOid1);
                session.Commit();
                session.ClearServerCache();
            }

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginRead();
                ulong mOid2 = mats.Id;
                mats = (VelocityDbSchema.Person)session.Open(mOid2);
                session.Commit();
                session.ClearServerCache();
            }
        }