示例#1
0
 private ClassInfo()
 {
     _attributes = null;
     _original = new CommittedCIZoneInfo();
     _committed = new CommittedCIZoneInfo();
     _uncommitted = new CIZoneInfo();
     _oidInfo = new OidInfo();
     Position = -1;
     MaxAttributeId = -1;
     _attributesCache = new AttributesCache();
 }
示例#2
0
        public virtual void Test1WithoutCommit()
        {
            var stopWatch = new StopWatch();

            stopWatch.Start();
            var size        = 10000;
            var size2       = 5000;
            var nbFunctions = 10;

            DeleteBase(FileName);
            var odb = Open(FileName);
            var f1  = new VO.Login.Function("function 1");

            // Create Objects
            for (var i = 0; i < size; i++)
            {
                var p = new Profile("profile number " + i, f1);
                for (var j = 0; j < nbFunctions; j++)
                {
                    p.AddFunction(new VO.Login.Function(" inner function of profile : number " + i + " - " + j));
                }
                var user = new User("user name " + i, "user email " + i, p);
                odb.Store(user);
            }
            Println("created");
            // Updates 10 times the objects
            var query   = odb.Query <User>();
            var objects = query.Execute <User>();

            for (var k = 0; k < 10; k++)
            {
                objects.Reset();
                for (var i = 0; i < size2; i++)
                {
                    var user = objects.Next();
                    user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
                    odb.Store(user);
                }
            }
            Println("updated");
            // Delete the rest of the objects
            for (var i = size2; i < size; i++)
            {
                odb.Delete(objects.Next());
            }
            Println("deleted");
            // Check object count
            var query1 = odb.Query <User>();

            objects = query1.Execute <User>();
            AssertEquals(size2, objects.Count);
            // Check data of the objects
            var a = 0;

            while (objects.HasNext())
            {
                var user = objects.Next();
                AssertEquals("user name " + a, user.GetName());
                AssertEquals("user email " + a, user.GetEmail());
                AssertEquals(
                    "profile number " + a +
                    "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated",
                    user.GetProfile().GetName());
                a++;
            }
            Println("checked");
            for (var k = 0; k < 10; k++)
            {
                objects.Reset();
                for (var i = 0; i < size2; i++)
                {
                    var user = objects.Next();
                    user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-");
                    odb.Store(user);
                }
            }
            Println("re-updated");
            var query2 = odb.Query <User>();

            objects = query2.Execute <User>();
            var engine     = ((global::NDatabase.Odb)odb).GetStorageEngine();
            var uncommited =
                engine.GetSession().GetMetaModel().GetClassInfo(typeof(User).FullName, true).UncommittedZoneInfo;
            CIZoneInfo commited =
                engine.GetSession().GetMetaModel().GetClassInfo(typeof(User).FullName, true).CommitedZoneInfo;

            Println("Before commit : uncommited=" + uncommited);
            Println("Before commit : commited=" + commited);
            a = 0;
            while (objects.HasNext())
            {
                // println("a="+a);
                odb.Delete(objects.Next());
                a++;
            }
            AssertEquals(size2, a);
            var query3 = odb.Query <User>();

            AssertEquals(0, query3.Execute <User>().Count);
            AssertEquals(0, odb.Query <User>().Count());
            Println("deleted");
            odb.Close();
            stopWatch.End();
            Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds());
            if (stopWatch.GetDurationInMiliseconds() > 108438)
            {
                Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds());
            }
        }