我可以做映射到这样的查询:的领域之一是COUNT(*)NHibernate的
select id,name,address,(select count(*) from account where record_id=id) as counter
from data where id = :id
目前,我使用的是本地SQL。
class person
{
public virtual long Id{get;set;}
public virtual string Name{get;set;}
public virtual string Address{get;set;}
public virtual long Counter{get;set;}
}
映射:
<property name="Counter" formula="(select count(*) from account where record_id=id)" type="long"/>
好吧,现在我明白你想要使用的类。我调整了我的答案,请看看。 – 2011-02-14 07:46:44