0

I have data returned in this format:


| Name | WeeklyTotal | WeekEnd |


Name1 | 2 | 2014-03-07
Name2 | 4 | 2014-01-03
Name1 | 3 | 2014-02-28
Name3 | 3 | 2014-03-07

etc. I am trying to project this data on a chart, using google visualization. I need a linq statement that will group data into a object like: Week1 => { Name1 = 2, Name2 = 0, Name3 = 3}

Basically, for each week, return an object with Weekly totals for each Name on the list. I have not an idea of how I am even going to approach this.

Afroman Makgalemela
  • 690
  • 2
  • 8
  • 21
  • Are the names known ahead of time? Is the "object" for the grouping just some sort of dynamic JSON object (e.g. using Json.NET)? – Jon Skeet Mar 06 '14 at 07:10
  • I am looking for somthing similar to these: http://stackoverflow.com/questions/15927573/c-sharp-linq-or-lambda-expresion-group-by-week-ienumerable-list-with-date-field – Afroman Makgalemela Mar 06 '14 at 07:18
  • That doesn't really help to clarify it much for me, as we still don't know whether `Name1`, `Name2` etc are fixed or whether they vary. It's also not clear why you'd want 2014-03-07 to be "Week1"... what week numbering system are you interested in? – Jon Skeet Mar 06 '14 at 07:21
  • It doesnt necessarily have to be week1. I just need to group those items by week, for each name in the name column. I have a query: select count(ListingID) WeeklyTotal, name, WeekStart from ( select id, name, dateadd(week,datediff(day,'20000107',Datetime) / 7, '20000107') AS WeekStart from table ) as u group by name, WeekStart this, returns weeklytotal for each person, and the friday of that week. Now, from that data, I need to put different names with the same week ending in the same object. I hope that makes sense? – Afroman Makgalemela Mar 06 '14 at 07:27
  • 1
    Well you *still* haven't answered whether the "name" part is fixed or dynamic... which affects whether or not this can be done through an anonymous type, or whether it'll have to be more dynamic. – Jon Skeet Mar 06 '14 at 08:42

0 Answers0