首先我知道GroubBy多个属性尚未实现。Nhibernate GroupBy倍数和计数
我想要做的是
SELECT count(*)
FROM (
SELECT this_.SubmissionDate as y0_
FROM [Coupon] this_
WHERE this_.PaymentOrder_id is null
GROUP BY this_.SubmissionDate,
this_.Deal_id
) AS query
我在NHibernate的最好的是
Session.QueryOver<Coupon>().Select(Projections.Group<Coupon>(e => e.SubmissionDate),Projections.Group<Coupon>(e => e.Deal.Id)).Future<object[]>().Count()
带来整套,然后数了。
我发现this并创造了这个
var count = Session.CreateQuery("select count(*) from (select c.SubmissionDate from Coupon c where c.PaymentOrder.Id is null group by c.SubmissionDate, c.Deal.Id) as query").FutureValue<Int32>();
不工作。抛出一个
Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 21
Exception Details: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 21
多个异常
[QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 21]
NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException() +118
NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse() +416
会发生什么它? – 2011-05-26 13:26:35
编辑添加异常 – 2011-05-26 13:32:08
Antlr异常似乎是由于不正确的HQL语法。 请参阅:http://stackoverflow.com/questions/3799087/nhibernate-antlr-runtime-noviablealtexception。 像上面的链接一样,QuerySyntaxException是否包含异常? – Tomas 2011-05-26 14:07:34