Join Non ContentPart Table to ContentPart Table Using Orchard HQL API

大城市里の小女人 提交于 2019-12-06 06:31:17

问题


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??

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?


回答1:


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
);


来源:https://stackoverflow.com/questions/16321375/join-non-contentpart-table-to-contentpart-table-using-orchard-hql-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!