コード例 #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                if (disposing)
                {
                    // 释放托管代码
                    if (DBTrans != null)
                    {
                        DBTrans.Dispose();
                        DBTrans = null;
                    }
                    if (DBConn != null)
                    {
                        if (DBConn.State == ConnectionState.Open)
                        {
                            DBConn.Close();
                        }
                        DBConn.Dispose();
                        DBConn = null;
                    }
                }

                //释放非托管代码

                m_disposed = true;
            }
        }
コード例 #2
0
        public ActionResult GetEntity()
        {
            string        type       = Request.Params["type"];
            List <Entity> entities   = DBTrans.GetEntityByType(type);
            var           serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string        result     = serializer.Serialize(entities);

            return(Content(result, "application/json"));
        }
コード例 #3
0
        /// <summary>
        /// 提交数据库操作
        /// </summary>
        protected void Commit()
        {
            if (this.DBTrans != null)
            {
                DBTrans.Commit();
                DBTrans.Dispose();
                DBTrans = null;
            }
            if (DBConn.State == ConnectionState.Open)
            {
                DBConn.Close();
            }

            DBConn.Dispose();
            DBConn = null;
        }
コード例 #4
0
ファイル: entity.cs プロジェクト: williamgoph/flatlandtest
    public static List <Entity> GetEntityByType(String _type)
    {
        DataTable     result   = DBTrans.ExecQuery("EXEC sp_query_GetEntityByType '" + _type + "'");
        List <Entity> entities = new List <Entity>();

        foreach (DataRow row in result.Rows)
        {
            Entity _entity = new Entity();
            _entity.ID      = Int32.Parse(row["id"].ToString());
            _entity.Type    = row["type"].ToString();
            _entity.Content = row["content"].ToString();
            _entity.Created = DateTime.Parse(row["created"].ToString());
            entities.Add(_entity);
        }

        return(entities);
    }
コード例 #5
0
        //MS SQL SErver 2005 sp3
        //
        // GET: /Test/

        public ActionResult Index()
        {
            return(Content(DBTrans.GetConfig("Config", "DBConnection")));
            //return View();
        }