public List <Tags_relationships> ListAllTagsRe() { if (!this.dt.OpenConnection()) { return(null); } string sqlquerry = "select * from Tags_relationships"; DataTable tb = dt.DATable(sqlquerry); List <Tags_relationships> lst = new List <Tags_relationships>(); foreach (DataRow r in tb.Rows) { Tags_relationships tgr = new Tags_relationships(); tgr.PostID = (int)r["PostID"]; tgr.TagsID = (int)r["TagsID"]; lst.Add(tgr); } this.dt.CloseConnection(); return(lst); }
public List <Tags_relationships> getTagsWithPostID(int postID) { if (!this.dt.OpenConnection()) { return(null); } string sqlquerry = "select * from Tags_relationships where PostID=@postID"; SqlParameter ppostID = new SqlParameter("@postID", postID); DataTable tb = dt.DATable(sqlquerry, ppostID); List <Tags_relationships> lst = new List <Tags_relationships>(); foreach (DataRow r in tb.Rows) { Tags_relationships tr = new Tags_relationships(); tr.PostID = (string.IsNullOrEmpty(r["PostID"].ToString())) ? 0 : (int)r["PostID"]; tr.TagsID = (string.IsNullOrEmpty(r["TagsID"].ToString())) ? 0 : (int)r["TagsID"]; lst.Add(tr); } this.dt.CloseConnection(); return(lst); }