【发布时间】:2014-02-13 12:19:36
【问题描述】:
我正在尝试获取一组文章/博客的所有年份和月份的列表。
var query = (from article in _session.Query<Article>()
where article.Parent == articleList && article.PublishOn != null
group article by new {article.PublishOn.Value.Year, article.PublishOn.Value.Month}
into entryGroup
orderby entryGroup.Key.Year descending, entryGroup.Key.Month descending
select new ArchiveModel
{
Year = entryGroup.Key.Year,
Month = entryGroup.Key.Month,
Count = entryGroup.Count()
});
return query.ToList();
上述编译但 nHibernate 抛出:
System.NotSupportedException {"NewExpression"}
有没有一种方法可以使用 nHibernate 中的任何其他查询方法来创建此查询?
我确实设法使用 SQL Projects 并使用 YEAR(date) 让它工作,但是这并没有在 SQLlite 中运行。如果可能,我需要它与数据库无关。
【问题讨论】:
-
你使用什么版本的 NHibernate?
标签: c# nhibernate linq-to-nhibernate nhibernate-criteria