Search code examples
sql-serverentity-frameworkentity-framework-4

How can I aggregate date data with EntityFramework but without skipping entries with no data?


How can I aggregate data by week with EntityFramework but without skipping weeks for which there is no data? So, basically if there is no data for given week - I want to get 0 or NULL as a result for that week.


Solution

  • Agreeing with Luke's comment above, if you know the weeks included in the search, can you just push your results onto a pre-filled week->result Map of some type initialized to zero?

    A quick google shows this smarter than me guy likes this answer too:

    http://thenullreference.com/blog/analytical-queries-using-entity-framework-over-date-ranges-using-linq/