Hi,
I am using NHibernate 3 Alpha 2, and I am trying to do the number of posts per month
This is the code I came up with
List<PostMonthFrequency> monthFrequencies = _postRepository
.FindAll()
//.ToList() //<- if included works. however not desired
.OrderByDescending(x => x.PublishedOn)
.GroupBy(x => new {x.PublishedOn.Year, x.PublishedOn.Month})
.Select(post => new PostMonthFrequency { Month = new DateTime(post.Key.Year, post.Key.Month, 01), Freqency = post.Count() }).ToList();
please not the FindAll will return the Session.Query()
I have also tried to remove the select
the error I get is:
NewExpression
Thats it.. I have got other expression to work well with the select, so i do not think it is that, more to do with the Groupby
Thanks in advance
PS my temp fix
List<PostMonthFrequency> monthFrequencies = _postRepository
.FindAll()
.Select(x => x.PublishedOn)
.ToList()
.GroupBy(x => new { x.Year, x.Month })
.Select(post => new PostMonthFrequency { Month = new DateTime(post.Key.Year, post.Key.Month, 01), Frequency = post.Count() })
.ToList();