/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.DistrictTable DataRowToModel(DataRow row) { Maticsoft.Model.DistrictTable model=new Maticsoft.Model.DistrictTable(); if (row != null) { if(row["DistrictID"]!=null) { model.DistrictID=row["DistrictID"].ToString(); } if(row["DistrictName"]!=null) { model.DistrictName=row["DistrictName"].ToString(); } if(row["CityID"]!=null) { model.CityID=row["CityID"].ToString(); } if(row["SortID"]!=null && row["SortID"].ToString()!="") { model.SortID=int.Parse(row["SortID"].ToString()); } if(row["SiteID"]!=null) { model.SiteID=row["SiteID"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.DistrictTable GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 DistrictID,DistrictName,CityID,SortID,SiteID from DistrictTable "); strSql.Append(" where "); SqlParameter[] parameters = { }; Maticsoft.Model.DistrictTable model=new Maticsoft.Model.DistrictTable(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }