我正在尝试使用Orchard HQL API在两个不同的表之间执行简单的联接。问题在于表之一不是ContentPartTable。这可能吗??
这是常规SQL中的样子:
Select * From ItemPartRecord
Join ItemRecord
On ItemRecord.ItemId = ItemPartRecord.ItemId
Where ItemRecord.Price Between 1000 and 10000
我到底该怎么做?
最佳答案
如果有人想知道如何执行此操作:
//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
);
关于asp.net-mvc - 使用Orchard HQL API将非ContentPart表连接到ContentPart表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16321375/