/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Dishes DataRowToModel(DataRow row) { Maticsoft.Model.Dishes model=new Maticsoft.Model.Dishes(); if (row != null) { if(row["DishesID"]!=null) { model.DishesID=row["DishesID"].ToString(); } if(row["DishesName"]!=null) { model.DishesName=row["DishesName"].ToString(); } if(row["DishesMoney"]!=null) { model.DishesMoney=row["DishesMoney"].ToString(); } if(row["popularity"]!=null) { model.popularity=row["popularity"].ToString(); } if(row["StoreId"]!=null) { model.StoreId=row["StoreId"].ToString(); } if(row["PictureName"]!=null) { model.PictureName=row["PictureName"].ToString(); } if(row["dishTypeID"]!=null) { model.dishTypeID=row["dishTypeID"].ToString(); } if(row["DishesUnit"]!=null) { model.DishesUnit=row["DishesUnit"].ToString(); } if(row["DishesBrief"]!=null) { model.DishesBrief=row["DishesBrief"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Dishes GetModel(string DishesID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 DishesID,DishesName,DishesMoney,popularity,StoreId,PictureName,dishTypeID,DishesUnit,DishesBrief from Dishes "); strSql.Append(" where DishesID=@DishesID "); SqlParameter[] parameters = { new SqlParameter("@DishesID", SqlDbType.NVarChar,50) }; parameters[0].Value = DishesID; Maticsoft.Model.Dishes model=new Maticsoft.Model.Dishes(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }