与Manytomany的NHibernate查询
-
29-09-2019 - |
题
我正在学习查询的过程中,但是我无法弄清楚如何做很多问题。
我写了以下内容:
var result = Session.CreateCriteria(typeof (Product))
.CreateAlias("Categories", "categories")
.Add(Property.ForName("categories.Id").Eq(categoryId))
.List<Product>();
这实现了预期的结果。我基本上有
产品> productCategory <类别
productCategory只有ProductID / categoryID,我正在尝试选择特定类别中的所有产品。
我不知道从哪里开始尝试使用查询。
解决方案
我最终在毅力之后解决了这个问题。
var result = Session.QueryOver<Product>()
.Right.JoinQueryOver<Category>(x => x.Categories)
.Where(c => c.Id == categoryId)
.List();
多么的任务:)
不隶属于 StackOverflow