예제 #1
0
        public JsonResult Remote_Data_Binding_Get_Employees(int?id)
        {
            var dataContext = new TestDBModel();

            var query = dataContext.Jobs.AsQueryable();

            if (id == null)
            {
                query = query.Where(a => a.ParentCode == null);
            }
            else
            {
                query = query.Where(a => a.ParentCode == id);
            }

            var result = query.Select(a => new Node
            {
                id          = a.ID,
                Name        = a.TitlePost,
                hasChildren = dataContext.Jobs.Any(b => b.ParentCode == a.ID),
                parentCode  = a.ParentCode
            }).ToList();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <summary>
        /// 取得姓名
        /// </summary>
        /// <returns></returns>
        public TestDBModel GetName()
        {
            TestDBModel testDBModel = new TestDBModel();

            using (SqlConnection cn = new SqlConnection(sqlConStr))
            {
                string sql = "select Top(1) name from Test";
                testDBModel = cn.Query <TestDBModel>(sql).Single();
            }
            return(testDBModel);
        }
예제 #3
0
        public async Task CreateTest(TestDBModel model)
        {
            using (var connection = _dbConnections(ConnectionKind.Create))
                using (var command = GetCommand(connection, _CreateTestSql))
                    using (var tx = connection.BeginTransaction())
                    {
                        command.Transaction = (MySqlTransaction)tx;

                        AddParameter(command, "@SomeIntData", DbType.Int32, model.SomeIntData);
                        AddParameter(command, "@SomeTextData", DbType.String, model.SomeTextData);
                        AddParameter(command, "@SomeSerializableData", DbType.Object, model.SomeSerializableData);
                        await command.ExecuteScalarAsync(_cancellationTokenSource.Token);

                        tx.Commit();
                    }
        }
예제 #4
0
 public void UpdateTest(int uId, TestDBModel model)
 {
     throw new NotImplementedException();
 }