0

Given an aggregate root X, which has many Y, and Y which has many Z...

How can I drill down through the associations and select only those X's whose Z's have a certain property value?

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

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

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

  • it might help if you specify real-world mappings and names and the XML mapping file, at least the section which concerns X, Y and Z. – Frans Bouma May 15 '09 at 19:02

1 Answers1

1

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

asgerhallas
  • 16,890
  • 6
  • 50
  • 68