public List<ArticleModel> GetArticles(string strQuery) { ConnManager connManager = new ConnManager(); connManager.OpenConnection(); DataSet DSQuestions = new DataSet(); DSQuestions = connManager.GetData(strQuery); connManager.DisposeConn(); List<ArticleModel> articles = new List<ArticleModel>(); ArticleModel article; foreach (DataRow row in DSQuestions.Tables[0].Rows) { article = new ArticleModel(); article.ArticleID = row["ArticleID"].ToString(); article.ArticleTitle = row["ArticleTitle"].ToString(); article.InsertedDate = row["InsertedDate"].ToString(); article.ThumbsUp = row["ThumbsUp"].ToString(); article.ThumbsDown = row["ThumbsDown"].ToString(); article.Views = row["Views"].ToString(); articles.Add(article); } return articles; }
public List<ArticleModel> GetArticles(string sqlQuery) { OpenConnection(); DataTable DSQuestions = new DataTable(); DSQuestions = GetDataTable(sqlQuery); DisposeConn(); List<ArticleModel> articles = new List<ArticleModel>(); ArticleModel article; foreach (DataRow row in DSQuestions.Rows) { article = new ArticleModel(); article.ArticleID = row["ArticleID"].ToString(); article.ArticleDetails = row["ArticleDetails"].ToString(); article.ArticleTitle = row["ArticleTitle"].ToString(); article.InsertedDate = row["InsertedDate"].ToString(); article.ThumbsUp = row["ThumbsUp"].ToString(); article.ThumbsDown = row["ThumbsDown"].ToString(); article.Views = row["Views"].ToString(); articles.Add(article); } return articles; }