1

我正在尝试让标签云架构在 NHibernate 中工作。

public class Tag : Entity
{
    public virtual int Id { get; set; }
    public virtual string Text { get; set; }
}

该表将映射到我的架构中的一些实体,因此我不想为每个关联向 Tag 类添加一个集合。

但是,我确实想查询标记实体并在所有连接表中返回 count(*)。我可以在 SQL 中轻松地做到这一点,但我还没有看到 NH 的光明。

开始写一些 HQL。

select t.Text, count(t.Id) 
from Tag t join ????
where t.Id= :tagid 
   group by t.Text

我加入什么?由于在对象模型中多对多桥表没有类和属性,这是否意味着这不能工作?

你有什么建议?我有兴趣看看这是否可以在标准中完成。

非常感谢,

伊恩

4

1 回答 1

1

作为开始使用 Criteria 怎么样,我没有运行它,我不知道如何进行连接......

 IList multiResults = s.CreateMultiCriteria()
     .Add(s.CreateCriteria(typeof(Tag)).SetProjection(Projections.RowCount()))
     .List();
于 2009-06-07T00:17:52.083 回答