2

NHibernate多个实体之间的 查询条件Or

如下错误代码生成了查询条件[where (lcAddress.Branch like '%%' or lcAddress.Branch like '%%' ) and (lccompany.CompanyName like '%%') ]:
return (List)NhibernateHelper.ISession.CreateCriteria(typeof(lcAddress))
.Add(
Expression.Disjunction()
.Add(Expression.Like("Branch", KeyWord, MatchMode.Anywhere))
.Add(Expression.Like("Address", KeyWord, MatchMode.Anywhere))
)
.CreateCriteria("Company")
.Add(Restrictions.Like("CompanyName", KeyWord, MatchMode.Anywhere))
.SetResultTransformer(new NHibernate.Transform.DistinctRootEntityResultTransformer())
.List();
我要实现的效果是[where (lcAddress.Branch like '%%' or lcAddress.Branch like '%%' and lccompany.CompanyName like '%%') ]
代码该怎么写?

查看全部
desailly
desailly
2015/08/21 09:45
  • hibernate
  • 点赞
  • 收藏
  • 回答
    私信

2个回复