字段之一是count(*)NHibernate [英] one of the fields is count(*) NHibernate
本文介绍了字段之一是count(*)NHibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以这样映射查询吗:
Can I do mapping to query like this :
select id,name,address,(select count(*) from account where record_id=id ) as counter
from data where id = :id
当前,我正在使用本机SQL.
Currently , I'm using a native 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"/>
推荐答案
是的,您应该使用公式.
您的映射可能如下所示:
Your mappings might look like this:
<property name="CountOfAccounts"
formula="(select count(*) from account where account.id = id)"/>
这篇关于字段之一是count(*)NHibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文