I am querying my database which has the following
Table: TimeEntries
- field1: ProjectName
- field2: Phase
- field3: TimeWorked
What I am trying to do is group by ProjectName and Phase and sum() the TimeWorked for each.
So if I had this in the table for: ProjectName, Phase, Timeworked
- Project1--- 1 --- 3.5
- Project1 --- 1 --- 2
- Project2 --- 1 --- 1
My query would return:
- Project1---1---5.5
- Project2---1---1
currently this is what I have:
var query3 = (from timeEntry in context.TimeEntries
select new
{
ProjectName = timeEntry.ProjectName,
Phase = timeEntry.Phase,
LoggedHours = context.TimeEntries.Sum(x => x.TimeWorked)
});
Not sure if I am even on the right track, could someone help me out?
Here is a picture of the database tables with their data types: TimeEntry Table, Project Table