/// <summary> /// 获取回复列表,实现分页 /// </summary> /// <param name="id"></param> /// <param name="startIndex"></param> /// <param name="len"></param> /// <returns></returns> public static IList <ForumMessageReply> GetFromDbByRootMsgId(Guid id, int startIndex, int len) { IList <ForumMessageReply> list = new List <ForumMessageReply>(); using (DbDataReader db = DataHelper.GetPageList("fbs_Message", "CreationDate", "ParentMessageID='" + id.ToString() + "'", startIndex, len)) { while (db.Read()) { list.Add(ForumMessageReply.CreateFromReader(db)); } } //StringBuilder strSql = new StringBuilder(); //strSql.Append("SELECT top ("+len.ToString()+") * FROM fbs_Message "); //strSql.Append(" WHERE ParentMessageID=@in_ParentMessageID ORDER BY CreationDate ASC"); //DbParameter[] cmdParms = new DbParameter[]{ // DataHelper.CreateInDbParameter("@in_ParentMessageID", DbType.Guid, id)}; //using (DbDataReader dr=DataHelper.ExecuteReader(CommandType.Text, strSql.ToString(), cmdParms)) //{ // while (dr.Read()) // { // list.Add(ForumMessageReply.CreateFromReader(dr)); // } //} return(list); }
internal static ForumMessageReply GetByKey(Guid key) { ForumMessageReply target = null; using (DbDataReader db = DataHelper.ExecuteReader(CommandType.Text, "select * from fbs_Message where MessageID='" + key.ToString() + "'")) { if (db.Read()) { target = ForumMessageReply.CreateFromReader(db); } } return(target); }