与NHibernate和Criteria结合? [英] Union with NHibernate and Criteria?

查看:100
本文介绍了与NHibernate和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆