与NHibernate和Criteria结合? [英] Union with NHibernate and Criteria?
问题描述
具有NHibernate和条件的联盟:
Union with NHibernate and Criteria:
在Criteria或QueryOver中是否可能? 如果没有,是否还有其他方法可以在同一查询中实现两个结果的并集?
Is it possible in Criteria or QueryOver? If not, is there any other way to achieve a union of two result within the same query?
推荐答案
您不能直接进行联合,但可以在以后进行两个查询并将结果合并为代码:
You can't do a union directly, but you can do two future queries and union the results in code:
var resultSet1 = this.Session.CreateCriteria<A>().Future<A>();
var resultSet2 = this.Session.CreateCriteria<B>().Future<B>();
此后,当枚举任何一个结果集时,NHibernate都会向数据库发出一个查询,该查询将返回多个结果集.请注意,如果您不使用SQL Server,则数据库可能不支持多个结果集.
After this, when either result set is enumerated, NHibernate will issue a single query to the database which will return multiple result sets. Note, if you are not using SQL Server, the database may not support multiple result sets.
这篇关于与NHibernate和Criteria结合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!