使用 ICriteria 接口选择不在 NHibernate 集合中的对象
在我的系统中,用户拥有 0 个或多个类别。这是我的模型类的简化版本:
public class User
{
public virtual String Name {get; set;}
public virtual IList<Category> Categories { get; set; }
}
public class Category
{
public virtual String Title {get; set;}
}
我现在想要创建一个 ICriteria 查询来选择所有未分配给用户的类别,但我陷入困境。理想情况下,我不想创建从类别到用户的导航属性,但以我对 NHibernate 的初学者了解,这是我能看到的唯一解决方案。
是否有 ICriteria 查询可以对当前数据模型类执行此操作?
感谢您的帮助。
In my system Users own 0 or more Categories. Here is a simplified version of my model classes:
public class User
{
public virtual String Name {get; set;}
public virtual IList<Category> Categories { get; set; }
}
public class Category
{
public virtual String Title {get; set;}
}
I now want to create an ICriteria query to select all categories that aren't assigned to a user, but I'm stuck. Ideally I don't want to create a navigation property from Category to User, but with my beginner knowledge of NHibernate that's the only solution I can see.
Is there an ICriteria query that will do this with the current data model classes?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这超出了我的想象,但可能是一个有用的指针。
您可能可以感受到这里将生成的 SQL:
希望这有帮助,抱歉我无法测试它:)
Tobin
This is off the top of my head, but might be a useful pointer.
You can probably get a feel for the SQL that will be generated here:
Hope this helps, and sorry I haven't been able to test it :)
Tobin