I'm having difficulty writing a Criteria to select all entities with empty child collections or empty grand-child collections. I can do these as seperate Criteria but I'm having trouble combining into a single Criteria.
class structure:
public class Component
{
public IList<Version> Versions { get; set; }
}
public class Version
{
public IList<SubscribeEvent> SubscribedEvents { get; set; }
public IList<PublishEvent> PublishedEvent { get; set; }
}
This does not work:
return session
.CreateCriteria<Component>("c")
.CreateCriteria("Versions", "v")
.Add(Restrictions.Or(Restrictions.IsEmpty("c.Versions"), Restrictions.And(Restrictions.IsEmpty("v.PublishedEvents"),
Restrictions.IsEmpty("v.SubscribedEvents"))))
.SetCacheable(true);