/// <summary> /// 获得数据列表 /// </summary> public List<DB_Talk.Model.m_AP> DataTableToList(DataSet ds) { List<DB_Talk.Model.m_AP> modelList = new List<DB_Talk.Model.m_AP>(); if (ds == null) return modelList; DataTable dt = ds.Tables[0]; int rowsCount = dt.Rows.Count; if (rowsCount > 0) { DB_Talk.Model.m_AP model; for (int n = 0; n < rowsCount; n++) { model = new DB_Talk.Model.m_AP(); if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="") { model.ID=int.Parse(dt.Rows[n]["ID"].ToString()); } if(dt.Rows[n]["vc_Name"]!=null && dt.Rows[n]["vc_Name"].ToString()!="") { model.vc_Name= dt.Rows[n]["vc_Name"].ToString(); } if(dt.Rows[n]["vc_Mac"]!=null && dt.Rows[n]["vc_Mac"].ToString()!="") { model.vc_Mac= dt.Rows[n]["vc_Mac"].ToString(); } if(dt.Rows[n]["vc_Memo"]!=null && dt.Rows[n]["vc_Memo"].ToString()!="") { model.vc_Memo= dt.Rows[n]["vc_Memo"].ToString(); } if(dt.Rows[n]["i_Flag"]!=null && dt.Rows[n]["i_Flag"].ToString()!="") { model.i_Flag=int.Parse(dt.Rows[n]["i_Flag"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 根据条件得到一个对象实体 /// </summary> public DB_Talk.Model.m_AP GetModel(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append(" select top 1 "); strSql.Append(" ID, vc_Name, vc_Mac, vc_Memo, i_Flag "); strSql.Append(" from m_AP "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } DB_Talk.Model.m_AP model=new DB_Talk.Model.m_AP(); DataSet ds=GetDataSet(strSql.ToString()); if(ds!=null && ds.Tables[0].Rows.Count>0) { model=DataTableToList(ds)[0]; return model; } else { return null; } }