/// <summary> /// 得到一个对象实体 /// </summary> public Thigh.Model.News DataRowToModel(DataRow row) { Thigh.Model.News model=new Thigh.Model.News(); if (row != null) { if(row["NewsID"]!=null && row["NewsID"].ToString()!="") { model.NewsID=int.Parse(row["NewsID"].ToString()); } if(row["NewsTitle"]!=null) { model.NewsTitle=row["NewsTitle"].ToString(); } if(row["NewsContent"]!=null) { model.NewsContent=row["NewsContent"].ToString(); } if(row["Keywords"]!=null) { model.Keywords=row["Keywords"].ToString(); } if(row["Description"]!=null) { model.Description=row["Description"].ToString(); } if(row["PicUrl"]!=null) { model.PicUrl=row["PicUrl"].ToString(); } if(row["PubTime"]!=null) { model.PubTime=row["PubTime"].ToString(); } if(row["Source"]!=null) { model.Source=row["Source"].ToString(); } if(row["ClickTime"]!=null) { model.ClickTime=row["ClickTime"].ToString(); } if(row["State"]!=null) { model.State=row["State"].ToString(); } if(row["NewsTypeID"]!=null) { model.NewsTypeID=row["NewsTypeID"].ToString(); } if(row["NewsTypeName"]!=null) { model.NewsTypeName=row["NewsTypeName"].ToString(); } if(row["AdminID"]!=null) { model.AdminID=row["AdminID"].ToString(); } if(row["AdminName"]!=null) { model.AdminName=row["AdminName"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Thigh.Model.News GetModel(int NewsID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select NewsID,NewsTitle,NewsContent,Keywords,Description,PicUrl,PubTime,Source,ClickTime,State,NewsTypeID,NewsTypeName,AdminID,AdminName from tb_News "); strSql.Append(" where NewsID=@NewsID"); OleDbParameter[] parameters = { new OleDbParameter("@NewsID", OleDbType.Integer,4) }; parameters[0].Value = NewsID; Thigh.Model.News model=new Thigh.Model.News(); DataSet ds=DbHelperOleDb.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }