示例#1
0
        public void PopulateAndDeleteNonExisting()
        {
            var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person)));

            for (var i = 0; i < 1000; i++)
            {
                tbl.Insert(new Person {
                    ID           = "POP{0}".Args(i),
                    FirstName    = "Oleg",
                    LastName     = "Popov-{0}".Args(i),
                    DOB          = new DateTime(1953, 12, 10),
                    YearsInSpace = 12
                });
            }

            var delete = new Person {
                ID = "NONE17"
            };

            var idx = tbl.Delete(delete);  //<-------------!!!!!!

            Aver.IsTrue(idx == -1);
            Aver.AreEqual(1000, tbl.Count);

            var match = tbl.FindByKey("POP17") as Person;

            Aver.IsNotNull(match);
        }
示例#2
0
        public void Save()
        {
            var rowset = new Rowset(Schema.GetForTypedDoc(typeof(MyPerzon)));

            rowset.LogChanges = true;

            for (var i = 0; i < 100; i++)
            {
                rowset.Insert(new MyPerzon
                {
                    GDID = new GDID(1, 1, (ulong)i),
                    Name = "Jeka Koshmar",
                    Age  = i
                });
            }

            var qryBetween5060 = new Query("CRUD.LoadPerzonsInAgeSpan", typeof(MyPerzon))
            {
                new Query.Param("fromAge", 50),
                new Query.Param("toAge", 60)
            };

            var rs = m_Store.LoadOneRowset(qryBetween5060);

            Aver.IsNotNull(rs);

            Aver.AreEqual(0, rs.Count);

            m_Store.Save(rowset);
            rowset.PurgeChanges();

            rs = m_Store.LoadOneRowset(qryBetween5060);
            Aver.IsNotNull(rs);

            Aver.AreEqual(9, rs.Count);

            rowset[55]["Age"] = 900;   //falls out of query
            rowset.Update(rowset[55]);
            rowset.Delete(rowset[59]); //physically deleted
            m_Store.Save(rowset);

            rs = m_Store.LoadOneRowset(qryBetween5060);
            Aver.IsNotNull(rs);

            Aver.AreEqual(7, rs.Count);
            Aver.AreObjectsEqual(58, rs.First()["Age"]);
            Aver.AreObjectsEqual(51, rs.Last()["Age"]);
        }
示例#3
0
文件: Rowsets.cs 项目: azist/azos
        public void LogChanges_Delete()
        {
            var tbl = new Rowset(Schema.GetForTypedDoc(typeof(Person)));

            tbl.Insert(new Person
            {
                ID           = "POP1",
                FirstName    = "Oleg",
                LastName     = "Popov",
                DOB          = new DateTime(1953, 12, 10),
                YearsInSpace = 12
            });
            tbl.LogChanges = true;

            tbl.Delete(tbl[0]);

            Aver.AreEqual(1, tbl.ChangeCount);
            Aver.AreEqual(0, tbl.Count);

            Aver.IsTrue(DocChangeType.Delete == tbl.GetChangeAt(0).Value.ChangeType);
        }
示例#4
0
文件: Rowsets.cs 项目: filmor/nfx
        public void PopulateAndDeleteExisting_UsingValues()
        {
            var tbl = new Rowset(Schema.GetForTypedRow(typeof(Person)));

            for (var i = 0; i < 1000; i++)
            {
                tbl.Insert(new Person {
                    ID           = "POP{0}".Args(i),
                    FirstName    = "Oleg",
                    LastName     = "Popov-{0}".Args(i),
                    DOB          = new DateTime(1953, 12, 10),
                    YearsInSpace = 12
                });
            }

            var idx = tbl.Delete("POP17");  //<-------------!!!!!!

            Assert.IsTrue(idx >= 0);
            Assert.AreEqual(999, tbl.Count);

            var match = tbl.FindByKey("POP17") as Person;

            Assert.IsNull(match);
        }