I am trying to get a group by followed by an order by count to work but I keep getting a 'Antlr.Runtime.NoViableAltException' being thrown.

Here is the simplest error case I can create.

var results = ArticleStatsRepository.GetAll().GroupBy(x => x.Article.ArticleId)
               .OrderBy(x => x.Count()); 

ArticleStatsRepository.GetAll() returns an IQueryable of ArticleStats.

public class ArticleStats
{
    public virtual int ArticleStatsId { get; set; }
    public virtual Article Article { get; set; }
    public virtual User Viewer { get; set; }
    public virtual ArticleStatTypeEN ArticleStatType { get; set; }
    public virtual DateTime DateTime { get; set; }
}

Ultimately I would like the following query to execute.

return ArticleStatsRepository.GetAll()
                  .Where(x => x.DateTime > DateTime.Now.Add(-timeSpan))
                  .Where(x => x.ArticleStatType == ArticleStatTypeEN.View)
                  .GroupBy(x => x.Article.ArticleId)
                  .Select(x => new { ArticleId = x.Key, Count = x.Count() })
                  .OrderByDescending(x => x.Count)
                  .Join(ArticleRepository.GetAll(), artStats => artStats.ArticleId, articles => articles.ArticleId, (artStats, articles) => new MostPopularArticleResult { ArticleId = artStats.ArticleId, ArticleTitle = articles.Content.Title, Count = artStats.Count });

I am using Fluent NHibernate 1.2.0.712 which references NHibernate: 3.1.0.4000.

Any help would be greatly appreciated!

Regards

Steve

Update: This is how I got round the issue. Not perfect as I didn't want to start using HQL with its QueryOver and would of liked to stick to IQueryable throughout.

    public virtual IQueryable<MostPopularArticleResult> GetMostPopularArticleResults(TimeSpan timeSpan, IQueryable<Article> filte
Edit
Report