本文介绍了使用NHibernate ICriteria / QueryOver查询向外连接添加条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在外连接表上需要一些额外的条件

,但NHibernate总是把它们添加到WHERE子句的最后 - 它没有得到正确的行为(参见



用Criteria看看
CreateAlias(字符串关联路径,字符串别名,JoinType连接类型,ICriterion withClause)
CreateCriteria(字符串关联路径,字符串别名,JoinType连接类型,ICriterion withClause)

使用QueryOver它不可用,但是这里有一个JIRA:


Is there a way to specify additional conditions on outer joins in NHibernate when querying using QueryOver or ICriteria?

I need some extra conditions on the outer join-ed table, but NHibernate always adds them to the WHERE clause at the end - which does not get the correct behaviour (see http://weblogs.sqlteam.com/jeffs/archive/2007/05/14/criteria-on-outer-joined-tables.aspx).

I can't seem to find any way to do this using Criteria or the QueryOver syntax...

Thanks

解决方案

(Answered my own question - sorry!)

Fabio answered a similar query on the NHibernate list - just thought I'd post it here.

That is possible with Criteria since NH3.0.The feature in HQLhttp://fabiomaulo.blogspot.com/2009/05/nhibernate-210-hql-with-clause.html

With Criteria have a look toCreateAlias(string associationPath, string alias, JoinType joinType, ICriterion withClause)CreateCriteria(string associationPath, string alias, JoinType joinType, ICriterion withClause)

With QueryOver it is not available but there's a JIRA for this here: https://nhibernate.jira.com/browse/NH-2592

这篇关于使用NHibernate ICriteria / QueryOver查询向外连接添加条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 00:05