[英]Failed to GroupBy with NHibernate LINQ
I'm having hard times to perform simple grouping on my entities. 我很难对实体进行简单的分组。 The faulting line of code is 代码的错误行是
var xxx = jobQuery.GroupBy(j => j.EverifyCase)
.Select(g => new { EC = g.Key, MRJ = g.Last() })
.ToList();
This gives me the following HibernateException: 这给了我下面的HibernateException:
Query Source could not be identified: ItemName = < generated >_1, ItemType = EverifyCaseJob, Expression = from EverifyCaseJob _1 in [ec] 无法识别查询来源:[ec]中的ItemName = <生成> _1,ItemType = EverifyCaseJob,Expression =来自EverifyCaseJob _1
If I do jobQuery.ToList()
everything is peachy - so I guess the problem is with the GroupBy()
The "Query Source" could be identified as I use this entity all over the place, but not in conjunction with GroupBy()
so far. 如果我执行jobQuery.ToList()
一切都变桃了-那么我想问题出在GroupBy()
,因为我在整个地方都使用了这个实体, 所以可以识别“查询源”,但不能与GroupBy()
结合使用,所以远。
Any ideas? 有任何想法吗?
Also, could anyone explain what the error message means? 另外,任何人都可以解释错误消息的含义吗?
NHibernate version is 4.0.3.4000 NHibernate版本为4.0.3.4000
I also use Fluent NH - version 2.0.1.0 我也使用Fluent NH-2.0.1.0版
Sql is set based and has no order in a grouping group. Sql是基于设置的,在分组组中没有顺序 。 So it has no meaning of last in a group hence NHibernate can not translate it to sql. 因此它没有组中最后一个的含义,因此NHibernate无法将其转换为sql。 Max on the other side is well defined for a set and will work fine. 另一侧的Max可以很好地定义一个集合,并且可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.