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