Example #1
0
        /// <summary>
        /// 刪除模型(此方法還需要同步刪除模板中對於該模型的引用)
        /// </summary>
        /// <param name="modelId"></param>
        /// <returns></returns>
        internal bool DeleteModel(int modelId)
        {
            using (DbExecutor db = NewExecutor(IsolationLevel.ReadUncommitted))
            {
                db.Delete <ViewContent>(t => t.ModelID == modelId);
                db.Delete <ViewModel>(t => t.ID == modelId);

                db.Commit();
            }
            return(true);
        }
Example #2
0
        public void Update()
        {
            DbExecutor.Delete(connectionFactory(), "Departments", new { dept_no = "1" });
            DbExecutor.Insert(connectionFactory(), "Departments", new { dept_no = "1", dept_name = "name1" });

            using (var exec = new DbExecutor(connectionFactory(), IsolationLevel.ReadCommitted))
            {
                exec.Select <Departments>("select * from Departments where dept_no = 1")
                .First()
                .Is(x => x.dept_name == "name1");

                exec.Update("Departments", new { dept_name = "UpdateName" }, new { dept_no = 1 });

                exec.Select <Departments>("select * from Departments where dept_no = 1")
                .First()
                .Is(x => x.dept_name == "UpdateName");
            }

            DbExecutor.Select <Departments>(connectionFactory(), "select * from Departments where dept_no = 1")
            .First()
            .Is(x => x.dept_name == "name1");

            DbExecutor.Update(connectionFactory(), "Departments", new { dept_name = "UpdateName" }, new { dept_no = 1 });

            DbExecutor.Select <Departments>(connectionFactory(), "select * from Departments where dept_no = 1")
            .First()
            .Is(x => x.dept_name == "UpdateName");

            DbExecutor.Update(connectionFactory(), "Departments", new { dept_name = "Int32" }, new { dept_no = 1 });
        }
Example #3
0
        public void Delete()
        {
            using (var exec = new DbExecutor(connectionFactory(), IsolationLevel.ReadCommitted))
            {
                exec.Select <Type>("select * from Types")
                .Any(x => x.TypeId == 2)
                .Is(true);

                exec.Delete("Types", new { TypeId = 2 });

                exec.Select <Type>("select * from Types")
                .Any(x => x.TypeId == 2)
                .Is(false);
            }
        }
Example #4
0
        public void Delete()
        {
            DbExecutor.Delete(connectionFactory(), "Departments", new { dept_no = "2" });
            DbExecutor.Insert(connectionFactory(), "Departments", new { dept_no = "2", dept_name = "name2" });
            using (var exec = new DbExecutor(connectionFactory(), IsolationLevel.ReadCommitted))
            {
                exec.Select <Departments>("select * from Departments")
                .Any(x => x.dept_no == "2")
                .Is(true);

                exec.Delete("Departments", new { dept_no = "2" });

                exec.Select <Departments>("select * from Departments")
                .Any(x => x.dept_no == "2")
                .Is(false);
            }
        }
Example #5
0
        public void Insert()
        {
            using (var exec = new DbExecutor(connectionFactory(), IsolationLevel.ReadCommitted))
            {
                exec.Insert("Types", new { Name = "NewType1" });
                exec.TransactionComplete(); // Transaction Commit
            }
            DbExecutor.Insert(connectionFactory(), "Types", new { Name = "NewType2" });

            DbExecutor.Select <Type>(connectionFactory(),
                                     "select * from Types where Name like @Name", new { Name = "NewType%" })
            .Count()
            .Is(2);

            DbExecutor.Delete(connectionFactory(), "Types", new { Name = "NewType1" });
            DbExecutor.Delete(connectionFactory(), "Types", new { Name = "NewType2" });

            DbExecutor.Select <Type>(connectionFactory(),
                                     "select * from Types where Name like @Name", new { Name = "NewType%" })
            .Count()
            .Is(0);
        }
Example #6
0
        public void Insert()
        {
            DbExecutor.Delete(connectionFactory(), "Departments", new { dept_no = "1" });
            DbExecutor.Delete(connectionFactory(), "Departments", new { dept_no = "2" });
            using (var exec = new DbExecutor(connectionFactory(), IsolationLevel.ReadCommitted))
            {
                exec.Insert("Departments", new { dept_no = "1", dept_name = "name1" });
                exec.TransactionComplete(); // Transaction Commit
            }
            DbExecutor.Insert(connectionFactory(), "Departments", new { dept_no = "2", dept_name = "name2" });

            DbExecutor.Select <Departments>(connectionFactory(),
                                            "select * from Departments where dept_name like @dept_name", new { dept_name = "name%" })
            .Count()
            .Is(2);

            DbExecutor.Delete(connectionFactory(), "Departments", new { dept_name = "name1" });
            DbExecutor.Delete(connectionFactory(), "Departments", new { dept_name = "name2" });

            DbExecutor.Select <Departments>(connectionFactory(),
                                            "select * from Departments where dept_name like @dept_name", new { dept_name = "name%" })
            .Count()
            .Is(0);
        }