コード例 #1
0
        /// <summary>
        /// 单条数据
        /// 页面权限信息
        /// </summary>
        /// <param name="id">页面权限ID</param>
        /// <returns></returns>
        public string Select_Role_One(string id)
        {
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    var linq =
                        from t in db.SPT_Role_One(id)
                        select t;

                    List <SPT_Role_One_Result> it = new List <SPT_Role_One_Result>();
                    it = linq.ToList();

                    string ret = "";
                    // 判断是否取到数据
                    if (it != null && it.Count > 0)// 取到数据
                    {
                        ret += "{\"Table\":[";
                        for (int i = 0; i < it.Count; i++)
                        {
                            // 不是第一行 补逗号
                            if (i != 0)
                            {
                                ret += ",";
                            }

                            ret += "{"
                                   + "\"ID\":\"" + it[i].ID + "\""
                                   + ",\"Title\":\"" + it[i].Title + "\""
                                   + ",\"Remark\":\"" + it[i].Remark + "\""
                                   + "}";
                        }
                        ret += "]}";
                    }

                    return(ret);
                }
            }
            catch (Exception ex)
            {
                return("");
            }
        }