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