NHibernate: Select item with entry in element bag

前端 未结 2 639
醉梦人生
醉梦人生 2020-12-12 02:04

I have a class with property of list.

public class Paperboy{
     private int _id;
     private string _lastname;
     private string _firstname;
     privat         


        
2条回答
  •  一生所求
    2020-12-12 02:51

    Almost the same answer I just gave to previous NHibernate question: QueryOver IList property

    Based on this Q & A: NHibernate How do I query against an IList property?

    Where I tried to show that (as mentioned in the documentation) we can use magical word ".elements":

    17.1.4.1. Alias and property references

    So the query which will touch the string elements in your case

    //or.Add(Restrictions.Eq("AdditionalPhoneNumbers", number));
    or.Add(Restrictions.Eq("AdditionalPhoneNumbers.elements", number));
    

    And that will support filtering IList

提交回复
热议问题