3
嵌套多次後,我無法使DetachedCriteria正常工作,原因是DetatchedCriteria只能訪問高一層的別名實體。NHibernate:DetachedCriteria不止一次嵌套
下無法正常工作,例如:
var secondNestedCriteria = DetachedCriteria.For<Baz>("baz")
.SetProjection(Projections.Id())
.Add(Restrictions.EqProperty("baz.FooName", "foo.Name") // Doesn't work
.Add(Restrictions.EqProperty("baz.BarName", "bar.Name");
var firstNestedCriteria = DetachedCriteria.For<Bar>("bar")
.SetProjection(Projections.Id())
.Add(Restrictions.EqProperty("bar.FooName", "foo.Name")
.Add(Subqueries.Exists(secondNestedCriteria);
var criteria = Session.CreateCriteria<Foo>("foo")
.Add(Subqueries.Exists(firstNestedCriteria)
.List<Foo>();
有誰知道,不使用HQL涉及解決方法嗎?