NHibernate - drilling from the root of the unit

Considering the aggregate root of X, which has many Y and Y, which has many Z ...

How can I expand the associations and select only those Xs where Z has a specific property value?

IList Xs = Session.CreateCriteria (typeof (X)) .CreateAlias ​​("Ys", "Y") .CreateAlias ​​("Y.Zs", "Z") .Add (Expression.Eq ("Z. Property ", 1)) .list ();

Doing so results in a PropertyAccessException, and I have no idea why.

Loading all X and testing their Z properties would be massively redundant.

0


a source to share


1 answer


I tried this and in my test setup it works flawlessly. PropertyAccessExceotion can be about an unavailable setter or a type mismatch when the property is set. If you post some mapping code and entity entity it might help.



+1


a source







All Articles