.net MVC知识积累,当遇到一个页面有多个数据集合时可以采用哈希表来存贮集合。通过循环来读取数据!
业务层数据接口
/// <summary>
/// a计划
/// </summary>
public IManagerPlanRecover MPR { get; set; }
/// <summary>
/// b计划
/// </summary>
public IManagerPlanNutritionInfo MPNU { get; set; }
/// <summary>
/// c计划
/// </summary>
public IManagerPsychConPlan IMPCP { get; set; }
ToDayPlanKFandYyVM todaykfyy = new ToDayPlanKFandYyVM();//实例化一个实体模型来存储数据。
IDictionary ht = new Hashtable();实例化数据字典,键值对数据。
IList<PlanNutritionInfo> planrelist = MPNU.GetList(Plnu, 10, 1);数据集合
ht["plannu"] = planrelist;存贮对象
IList<PlanRecoverInfo> planrev = MPR.GetList(query, 10, 1);
ht["planrec"] = planrev;
IList<PsychConPlanInfo> pslst = IMPCP.GetList(psinfo, 1, 1);
ht["psych"] = pslst;
StringBuilder strbuil = new StringBuilder();用字符串存放数据,返回页面显示。
foreach (DictionaryEntry de in ht)循环数据
{
if (de.Key.ToString() == "plannu")
{
foreach (PlanNutritionInfo plannutinfo in (de.Value as IList<PlanNutritionInfo>))
{
strbuiy.Append(plannutinfo.Weight);
strbuiy.Append(System.Environment.NewLine);
}
todaykfyy.YingYang = strbuiy.ToString();
}
else if (de.Key.ToString() == "planrec")
{
foreach (PlanRecoverInfo planrec in (de.Value as IList<PlanRecoverInfo>))
{
todaykfyy.BasicInfo = planrec.Aim;
}
}
}