示例#1
0
        /// <summary>
        /// 修改Demo(异步)
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Sex"></param>
        /// <param name="Age"></param>
        /// <param name="Remark"></param>
        /// <returns></returns>
        public async Task <bool> InsertDemoAsync(string Name, string Sex, int Age, string Remark)
        {
            try
            {
                _testRepository.BeginTran();//开始事务
                var              result    = false;
                long             Id        = IdWorkerHelper.NewId();
                string           sql       = "INSERT INTO Demo(Id,Name,Sex,Age,Remark) VALUES(@Id,@Name,@Sex,@Age,@Remark)";
                SugarParameter[] Parameter = new SugarParameter[]
                {
                    new SugarParameter("@Id", Id),
                    new SugarParameter("@Name", Name),
                    new SugarParameter("@Sex", Sex),
                    new SugarParameter("@Age", Age),
                    new SugarParameter("@Remark", Remark)
                };
                result = await _testRepository.ExecuteSqlAsync(sql, Parameter);

                _testRepository.CommitTran();//提交事务
                return(result);
            }
            catch (Exception ex)
            {
                _testRepository.RollbackTran();//回滚事务
                throw ex;
            }
        }