.net - Sum and Group By in Linq to Entities -


i'm trying sum of values grouping , i'm stuck. sample structure of table:

alt text

what want is:

user name, project name, total work time of project users, grouped user name , project name.

the trick need display 0 or null value if user in project , user doesn't have work time yet.

example result should this:

username  project  total time user1     project1 15 user1     project2 -- user2     project1 10 

how can accomplish this?

this scary select work, once add references (navigational properties)

db.users.selectmany(     x=> x.projects            .select(i=>                   new                   {                      user = x.name,                      project = i.name,                      worktime = (int?)i.userworktimes.sum(t=>t.worktime)                    })     );  

my assumptions are

  1. worktime of int type.

  2. nav.property projects projectuserworktimes called userworktimes

  3. nav.property users projects called projects


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -