c# - SQL query to LINQ expression -
how can translate sql query linq expression?
select notedate, sum( durationinhours ) note iduser = '2933fb9c-cc61-46da-916d-57b0d5ef4803' , notedate > '2013-07-01' group notedate
i tried it, didn't work
var lastmonth = datetime.today.addmonths(-1); var usernotes = getnotesbyuser(iduser); var b = note in usernotes group note new {note.iduser, note.notedate, note.durationinhours} g g.key.notedate > lastmonth select new {g.key.notedate, totalhours = g.sum(a => a.durationinhours)}
var id = new guid("2933fb9c-cc61-46da-916d-57b0d5ef4803"); var date = new datetime(2013, 7, 1); var query = n in db.notes n.iduser == id && n.notedate > date group n n.notedate g select new { notedate = g.key, sum = g.sum(x => x.durationinhours) };
Comments
Post a Comment