/// <summary> /// 获取友链通过sql语句 /// </summary> /// <param name="sql"></param> /// <returns></returns> private static List <FriendLink> GetLinkBySql(string sql) { List <FriendLink> list = new List <FriendLink>(); DataTable table = SSMS.GetDataSet(sql); foreach (DataRow row in table.Rows) { FriendLink friendlink = new FriendLink(); friendlink.Lid = (int)row["lid"]; friendlink.Ltitle = (string)row["ltitle"]; friendlink.Lhref = (string)row["lhref"]; friendlink.FLtime = (DateTime)row["fltime"]; friendlink.Luid = (int)row["luid"]; list.Add(friendlink); } return(list); }
/// <summary> /// 通过sql获得评论列表 /// </summary> /// <param name="sql"></param> /// <returns></returns> private static List <comments> GetCommentsBySql(string sql) { List <comments> list = new List <comments>(); DataTable table = SSMS.GetDataSet(sql); foreach (DataRow row in table.Rows) { comments comment = new comments(); comment.Title = (string)row["title"]; //标题 comment.Id = (int)row["id"]; //用户id comment.CId = (int)row["cid"]; //评论id comment.BlogId = (int)row["blogid"]; //文章id comment.Huifu = (string)row["huifu"]; //回复内容 comment.PubDate = (DateTime)row["Publictime"]; //回复时间 comment.Article = ArticleServer.GetArticleById((int)row["blogid"]); //通过文章id获取文章 list.Add(comment); } return(list); }
/// <summary> /// 通过sql获取 /// </summary> /// <param name="sql"></param> /// <param name="values"></param> /// <returns></returns> private static List <Article> GetArticlesBySql(string sql) { List <Article> list = new List <Article>(); DataTable table = SSMS.GetDataSet(sql); foreach (DataRow row in table.Rows) { Article article = new Article(); article.NID = (int)row["nID"]; article.NTitle = (string)row["ntitle"]; article.NContent = (string)row["ncontent"]; article.NDate = (DateTime)row["ndate"]; article.Nkey = (string)row["nkey"]; article.Aname = (string)row["aname"]; article.Author = UserServer.GetUserById((int)row["id"]); //FK list.Add(article); } return(list); }