加入非ContentPart表到ContentPart表使用果园HQL API [英] Join Non ContentPart Table to ContentPart Table Using Orchard HQL API

查看:114
本文介绍了加入非ContentPart表到ContentPart表使用果园HQL API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行使用乌节HQL API两个不同的表之间的简单连接。问题是,在表中的一个不是ContentPartTable。这是可能的?

I am trying to perform a simple join between two different tables using the Orchard HQL API. The problem is that one of the tables is not a ContentPartTable. Is this possible??

下面是它看起来像在普通的SQL:

Here is what it would look like in regular SQL:

Select * From ItemPartRecord 
Join ItemRecord
On ItemRecord.ItemId = ItemPartRecord.ItemId
Where ItemRecord.Price Between 1000 and 10000

我究竟怎么会去这样做呢?

How exactly could I go about doing this?

推荐答案

如果你想知道如何做到这一点:

If anyone is wondering how to do this:

 //Join the non content part table
var defaultHqlQuery = query as DefaultHqlQuery;
var fiJoins = typeof(DefaultHqlQuery).GetField("_joins", BindingFlags.Instance | BindingFlags.NonPublic);
var joins = fiJoins.GetValue(defaultHqlQuery) as List<Tuple<IAlias, Join>>;
joins.Add(new Tuple<IAlias, Join>(new Alias("ExampleNamespace.Data.Models"), new Join("ExampleRecord", "ExampleAlias", ",")));
Action<IHqlExpressionFactory> joinOn = predicate => predicate.EqProperty("valueToJoinOn", "aliasToJoinOn.valueToJoinOn");
query = query.Where(
alias => alias.Named("ExampleAlias"),
joinOn
);

这篇关于加入非ContentPart表到ContentPart表使用果园HQL API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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