Linq to nhibernate - Where collection contains object with id
问题 I have 2 objects like this public class Child { public virtual int ChildId { get; set; } } public class Parent { public virtual int ParentId { get; set; } public virtual IList<Child> Children { get; set; } } I am trying to write a linq to nhibernate query to select a parent where it contains a child with a specific id. return x => x.Children.Contains does not work. I also tried this. return x => (from y in x.Children where y.ChildId.Equals(childId) select y).Count() > 0 My fluent mapping