views:

33

answers:

1

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();
+3  A: 

The best place to post NHibernate bugs is on the official mailing list here.

Gareth
I think you are right, I have just raised the query there too.
dbones
it not been implemented yet.
dbones
Thanks for the post / question. I've been fighting this issue as well. At least I now know I just need to wait.
cdmdotnet