/// <summary> /// 得到一个对象实体 /// </summary> public Pan.Model.PageSet DataRowToModel(DataRow row) { Pan.Model.PageSet model=new Pan.Model.PageSet(); if (row != null) { if(row["id"]!=null && row["id"].ToString()!="") { model.id=int.Parse(row["id"].ToString()); } if(row["href"]!=null) { model.href=row["href"].ToString(); } if(row["column"]!=null) { model.column=row["column"].ToString(); } if(row["title"]!=null) { model.title=row["title"].ToString(); } if(row["keywords"]!=null) { model.keywords=row["keywords"].ToString(); } if(row["description"]!=null) { model.description=row["description"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Pan.Model.PageSet GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 id,href,[column],title,keywords,description from PageSet "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; Pan.Model.PageSet model=new Pan.Model.PageSet(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }