【发布时间】:2012-12-26 09:02:03
【问题描述】:
我通过为映射到视图的实体指定entity-name 将实体映射到表和视图,如下所示:
到表的映射:
<class name="Foo">
到视图的映射:
<class name="Foo" entity-name="LatestFoo">
然后我尝试在我的控制器中执行此操作:
var latestVersions = Database.QueryOver<Foo>("LatestFoo");
var count = latestVersions.RowCount();
但是对RowCount() 的调用会同时为表和视图运行 SQL 语句:
2012-12-26 13:30:55,700 [31] DEBUG NHibernate.SQL - SELECT count(*) as y0_ FROM LatestFoo this_
2012-12-26 13:30:55,705 [31] DEBUG NHibernate.SQL - SELECT count(*) as y0_ FROM Foo this_
这会导致NonUniqueResultException 带有消息query did not return a unique result: 2
我需要做什么才能让它工作?
【问题讨论】:
标签: nhibernate queryover