Lam*_*mpa 3 nhibernate nhibernate-mapping
我可以映射到这样的查询:
select id,name,address,(select count(*) from account where record_id=id ) as counter
from data where id = :id
Run Code Online (Sandbox Code Playgroud)
目前,我正在使用本机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;}
}
Run Code Online (Sandbox Code Playgroud)
映射:
<property name="Counter" formula="(select count(*) from account where record_id=id )" type="long"/>
Run Code Online (Sandbox Code Playgroud)
是的,你应该使用公式.
您的映射可能如下所示:
<property name="CountOfAccounts"
formula="(select count(*) from account where account.id = id)"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
648 次 |
| 最近记录: |