日期:2014-05-20 浏览次数:21109 次
var linqValue = from item in db.consume
                                group item by new
                                {
                                    item.je_createdate.Value.Year,
                                    item.je_createdate.Value.Month
                                } into g
                                select new
                                {
                                    monthday = String.Format("{0}年-{1}月",g.Key.Year,g.Key.Month),
                                    totalmoney = g.Sum(d => d.je_amount)
                                };
                dataGridView3.DataSource = linqValue;
var linqValue =( from item in db.consume
                                group item by new
                                {
                                    item.je_createdate.Value.Year,
                                    item.je_createdate.Value.Month
                                } into g
                                select new
                                {
                    Year=g.Key.Year,
                    Month=g.Key.Month,
                                    totalmoney = g.Sum(d => d.je_amount)
                                }).ToList().Select(t=>new{
                                   monthday = String.Format("{0}年-{1}月",t.Year,t.Month),
                                   totalmoney =t.totalmoney 
                                 };
                dataGridView3.DataSource = linqValue;