I don't know if there is a better way, but for this I use subqueries:
from Workflow w join w.Log l where l in ( select n from Note n where n.Content like '%keyword%' )
(if that doesn't work, write l.id in (select n.id... )
In criteria, you can directly filter properties that are available only in a subclass, but you shouldn't, because it only filters the first subtype that finds where this property is defined.
I also use subqueries:
DetachedCriteria subquery = DetachedCriteria.For<Note>("n") .Add(Expression.Like("n.Content", "%keyword%")) .SetProjection(Projections.Property("n.id")); IList<Workflow> workflows = session.CreateCriteria<Workflow>("w") .CreateCriteria("w.Log", "l") .Add(Subqueries.PropertyIn("l.id", subquery)) .List<Workflow>();
source share