It's labeled as "TODO" in the unit tests.  Depending on your data, you
could do the single groupby to pull the data, then run a secondary
groupby on the pulled data to get the grouping you're looking for.
Though I would recommend just using HQL.

On Aug 30, 8:51 am, Dave <[email protected]> wrote:
> 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"
>
> It seems to happen when I try multiple group by properties
>
> Thanks in advance
>
> Dave
>
> ps my current work around
>
> 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();

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to