NHibernate Criteria Collection Contains

前端 未结 1 746
滥情空心
滥情空心 2021-01-04 10:43

I have a parent/child relationship mapped with a many-to-many set.

public class Parent
{
    public ISet Children { get; set; }
}

public class          


        
相关标签:
1条回答
  • 2021-01-04 11:25

    How about something like this?

    Session.CreateCriteria<Parent>()
       .CreateCriteria("Children")
       .Add(Expression.Eq("Id", child.Id)
       .List<Parent>();
    

    or

    Session.CreateCriteria<Parent>()
       .CreateCriteria("Children")
       .Add(Expression.In("Id", child.Id)
       .List<Parent>();
    

    so you can pass in an array of Ids.

    0 讨论(0)
提交回复
热议问题