Example #1
0
        public void TestMove()
        {
            using (var db = new DbContext())
            {
                var rep = db.CreateTreeRepository <Depts>();
                //var dept = db.Depts.FirstOrDefault(s => s.DeptName == "昆明");
                var dept = Depts.New().Normalize(3L);
                dept.DeptName = "aaaa";
                var parent = db.Depts.FirstOrDefault(s => s.DeptName == "四川");

                rep.Move(dept, parent);

                db.Depts.Update(dept);
            }
        }
        public void TestBatchInsert()
        {
            using (var db = new DbContext())
            {
                var list = new List <Depts>();

                for (var i = 0; i < 3; i++)
                {
                    var d = Depts.New();
                    d.DeptName = "测试" + i;
                    list.Add(d);
                }

                db.Depts.Batch(list, (u, s) => u.Insert(s));
            }
        }
        public void TestSubscriberForBatch()
        {
            SubscribeManager.Register <EntityPersistentSubject>(new EntitySubscriber());

            using (var db = new DbContext())
            {
                var list = new List <Depts>();

                for (var i = 0; i < 3; i++)
                {
                    var d = Depts.New();
                    d.DeptID   = i + 50;
                    d.DeptName = "a" + i;
                    list.Add(d);
                }

                list[1].DeptCode = "test";

                db.Depts.Batch(list, (u, s) => u.Update(s));
            }
        }