日期:2014-05-20 浏览次数:20962 次
List<AFileTools.Model.ItemDataBase> lst = new List<AFileTools.Model.ItemDataBase>();
lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-1 20:00:00", Value = "1.1" });
lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-1 21:00:00", Value = "2.2" });
lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-2 20:00:00", Value = "3.1" });
lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-2 21:00:00", Value = "111.1" });
List<Model.ItemDataBase> lstData = new List<AFileTools.Model.ItemDataBase>();
lstData.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-1 20:00:00", Value = "1.1" });
lstData.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-1 21:00:00", Value = "2.2" });
lstData.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-2 20:00:00", Value = "3.1" });
lstData.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-2 21:00:00", Value = "111.1" });
IEnumerable<IGrouping<string, string>> query =
from Data in lstData
group Data by Data.DT.Substring(0, Data.DT.IndexOf(' ')) into g
select g.Average(s => float.Parse(s.Value));
//List<AFileTools.Model.ItemDataBase> lst = new List<AFileTools.Model.ItemDataBase>();
//lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-1 20:00:00", Value = "1.1" });
//lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-1 21:00:00", Value = "2.2" });
//lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-2 20:00:00", Value = "3.1" });
//lst.Add(new AFileTools.Model.ItemDataBase() { DT = "2010-1-2 21:00:00", Value = "111.1" });
var query = from q in db.GetList
group q by DateTime.Parse(q.DT).ToString("yyyy-MM-dd") into g