- private const string SQL_SELECT_DOUBLE = "select a.id, a.CategoryId, a.Title, a.FullTitle, a.Renqun, a.Hot, a.CreateTime, a.ImageUrl from food_Content AS a inner join food_Category AS b ON a.CategoryId = b.id WHERE (b.id =@id)";
- /// <summary>
- /// 返回同类别的所有文章
- /// </summary>
- /// <param name="id">类别id</param>
- /// <returns></returns>
- public IList<FoodInfo> GetContentInfoByCategoryId(int id) {
-
- IList<FoodInfo> Cateinfoes = new List<FoodInfo>();
- SqlParameter parm = new SqlParameter("@id", SqlDbType.Int);
- parm.Value = id;
- using (SqlDataReader sdr = SqlHelper.ExecuteReader(SqlCon, CommandType.Text, SQL_SELECT_DOUBLE, parm)) {
- if (sdr.Read()) {
- var Cateinfo = new FoodInfo() {
- Id = sdr.GetInt32(0),
- CategoryId = sdr.GetInt32(1),
- Title = sdr.GetString(2),
- FullTitle = sdr.GetString(3),
- Renqun = sdr.GetString(4),
- Hot = sdr.GetInt32(5),
- CreateTime = sdr.GetDateTime(6)
-
- };
- if (sdr.IsDBNull(7))
- Cateinfo.ImageUrl = string.Empty;
- else
- Cateinfo.ImageUrl = sdr.GetString(7);
- Cateinfoes.Add(Cateinfo);
- }
- }
- return Cateinfoes;
- }
复制代码 前台代码调出的却是文章的id 怎么回事 |