Пример #1
0
        public async Task AddAndRemove()
        {
            LCObject parent = new LCObject("Parent");
            LCObject c1     = new LCObject("Child");

            parent.AddRelation("children", c1);
            LCObject c2 = new LCObject("Child");

            parent.AddRelation("children", c2);
            await parent.Save();

            LCRelation <LCObject> relation = parent["children"] as LCRelation <LCObject>;
            LCQuery <LCObject>    query    = relation.Query;
            int count = await query.Count();

            TestContext.WriteLine($"count: {count}");
            Assert.AreEqual(count, 2);

            parent.RemoveRelation("children", c2);
            await parent.Save();

            int count2 = await query.Count();

            TestContext.WriteLine($"count: {count2}");
            Assert.AreEqual(count2, 1);
        }