Example #1
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"]);
        }