我是采用三层架构,根据日期分组来显示价格,并将价格以折线图的形式显示。
现在“价格”这个字段我在调试的过程中都没有显示出来,只有日期
/// <summary>
/// 总体价格走势
/// </summary>
/// <returns></returns>
public static object GetPrices()
{
XFMSDBHelpDataContext db = new XFMSDBHelpDataContext();
var dd = from p in db.Purchase
group p by p.DTime into f
select new
{
f.Key,
prices = f.Select(t=>t.price)
};
//var dd = db.Purchase.GroupBy(f => f.DTime).ToDictionary(g => g.Key, g => g.Select(p => p.price));
return dd.Select(x => new { Times = x.Key, prices = x.prices }).ToList();
}
------解决思路----------------------
var dd = from p in db.Purchase
group p by new{p.DTime,p.price} into f
select new
{
f.Key
};