我通过为映射到视图的实体指定一个实体,将实体映射到表和视图,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
我需要做什么才能使其正常工作?