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