示例#1
0
        //--------------------------------------------------------------------------
        public List <Post> init(SqlCommand cmd)
        {
            SqlConnection con = db.getConnection();

            cmd.Connection = con;
            List <Post> l_Post = new List <Post>();

            try
            {
                con.Open();
                SqlDataReader   reader      = cmd.ExecuteReader();
                SmartDataReader smartReader = new SmartDataReader(reader);
                while (smartReader.Read())
                {
                    Post m_Post = new Post();
                    m_Post.Post_id          = smartReader.GetInt32("Post_id");
                    m_Post.Post_Title       = smartReader.GetString("Post_Tile");
                    m_Post.Post_Type        = smartReader.GetInt32("Post_Type");
                    m_Post.Post_Description = smartReader.GetString("Post_Description");
                    m_Post.Post_Content     = smartReader.GetString("Post_Content");
                    m_Post.Post_Images      = smartReader.GetString("Post_Images");
                    m_Post.Post_CategoryID  = smartReader.GetString("Post_CategoryID");
                    m_Post.Post_Slug        = smartReader.GetString("Post_Slug");
                    m_Post.Post_tag         = smartReader.GetString("Post_tag");
                    m_Post.Post_UserID      = smartReader.GetInt32("Post_UserID");
                    m_Post.Post_Location    = smartReader.GetInt32("Post_Location");
                    m_Post.Post_CreateDate  = smartReader.GetDateTime("Post_CreateDate");
                    l_Post.Add(m_Post);
                }
                smartReader.disposeReader(reader);
                return(l_Post);
            }
            catch (SqlException err)
            {
                throw err;
            }
            finally
            {
                db.closeConnection(con);
            }
        }