在NHibernate中搜索多个列

在NHibernate中搜索多个列,nhibernate,Nhibernate,在NHibernate中如何执行以下操作 SELECT ContactName, ContactTel1, ContactTel2, ContactTel3 FROM tb_Contact WHERE (ContactTel1 LIKE '%6440%') OR (ContactTel2 LIKE '%6440%') OR (ContactTel3 LIKE '%6440%') 这就是我所拥有的,但我不知道如何对多个列执行相同的操作

在NHibernate中如何执行以下操作

    SELECT  ContactName, ContactTel1, ContactTel2, ContactTel3
    FROM tb_Contact
    WHERE (ContactTel1 LIKE '%6440%') OR
         (ContactTel2 LIKE '%6440%') OR
         (ContactTel3 LIKE '%6440%')
这就是我所拥有的,但我不知道如何对多个列执行相同的操作

  all = session.CreateCriteria(typeof(Contact)).Add(Expression.Like(pField,  "6440", MatchMode.Anywhere))
                 .List<Contact>();
all=session.CreateCriteria(typeof(Contact)).Add(Expression.Like(pField,“6440”,MatchMode.Anywhere))
.List();

非常感谢任何指针。

看看析取表达式

all = session.CreateCriteria (typeof(Contract))
                .Add (
                      Restrictions.Disjunction().Add (Restrictions.Like ("Tel1", "6440")
                                                .Add (Restrictions.Like ("Tel2", "6440")
                                                .Add (Restrictions.Like ("Tel3", "6440")
                     );

你错过了比赛模式

all = session.CreateCriteria (typeof(Contact))
                .Add (
                      Restrictions.Disjunction().Add (Restrictions.Like ("Tel1", "6440", MatchMode.Anywhere)
                                                .Add (Restrictions.Like ("Tel2", "6440", MatchMode.Anywhere)
                                                .Add (Restrictions.Like ("Tel3", "6440", MatchMode.Anywhere)
                     );

天哪,我不认为有必要给出完整详细的代码。我认为我的文章中的脱节部分对话题发起者来说是最重要的;那是缺失的部分。他可以自己写解决方案的剩余部分,不是吗?我们不是猴子,是不是。。。
all = session.CreateCriteria (typeof(Contact))
                .Add (
                      Restrictions.Disjunction().Add (Restrictions.Like ("Tel1", "6440", MatchMode.Anywhere)
                                                .Add (Restrictions.Like ("Tel2", "6440", MatchMode.Anywhere)
                                                .Add (Restrictions.Like ("Tel3", "6440", MatchMode.Anywhere)
                     );