hql实现select new Type(column) from table
string query1 = "select MAX(g.Stars) ,
new AuthorDTO(MAX(cast(g.GroupName as string))//不知道为什么不能加在聚合函数里面,也不能加到Group
from Group g join g.authors auths group by g.GroupName";
下面方式可以:
string query1 = "select g.Stars,
new AuthorDTO(cast(g.GroupName as string)//需要在Group.hbm.xml里面添加<import class="Gx.DTO.AuthorDTO,Gx.DTO"></import>,参考下面的xml
//new Group(cast(g.GroupName as string)
from Group g join g.authors auths group by g.GroupName";
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<import class="Gx.DTO.AuthorDTO,Gx.DTO"></import>
<class name="Entity.UpFileView, Entity" table="UpFileView">
<id name="Fid" column="Fid" type="Int32">
<generator class="identity" />
</id>