c# - LINQ group by not working -


i've read lots of group replies in forum, have ask anyway:

var errandquery = (from t in db.timereportset                    group t new { t.errand.name, t.date } g                    select new errandtime { date = g.key.date, value = g.sum(e => e.hours) }).tolist(); 

why isn't working. following exception: "unknown column 'groupby1.k1' in 'field list'"

the exception comes mysqlclient.

you're not selecting hours g, aren't there sum.

i don't know data looks try this:

edit:

var errandquery = (from t in db.timereportset                                        group t new { t.errand.name, t.date } g                                       select new errandtime { date = g.key.date, value = g.sum**(t => t.hours)** }).tolist();  

sorry, first response incorrect.

you linq query correct, except right @ end --- using e.. need reference items selected ... so need use t in lambda expression instead of e


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -