我无法找到有关如何针对信息集部分执行HQLQuery的任何示例。 我正在构建自定义日历/事件管理模块,需要查询即将发生的事件。我使用严格的信息集(没有EventPartRecord类),但我似乎无法正确查询。
每个日历可以显示多个事件类别,每个事件也可以显示多个事件类别。
以下代码产生代码后发布的错误:
public IEnumerable<EventPart> GetUpcomingEventsForCalendar(CalendarPart calendar,
VersionOptions versionOptions, int count)
{
versionOptions = versionOptions ?? VersionOptions.Published;
string[] ids = calendar.EventCategoryIds;
var events = _contentManager.HqlQuery()
.ForPart<EventPart>()
.Where(alias => alias.ContentItem() ,a=>
a.And(x => x.Ge("StartDate", DateTime.Today), y => y.InG("EventCategoryIds", ids)))
.OrderBy(x => x.ContentItem(), order => order.Asc("StartDate"))
.Slice(0, count);
return events;
}
错误:
Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator:
ERROR - QueryException thrown from IContentPartDriver by
Web.Module.Events.Drivers.CalendarWidgetPartDriver
NHibernate.QueryException: could not resolve property: StartDate of:
Orchard.ContentManagement.Records.ContentItemRecord [select distinct civ.Id as Id,
ci.StartDate
from Orchard.ContentManagement.Records.ContentItemVersionRecord as civ
join civ.ContentItemRecord as ci
where (ci.StartDate >= '2014-06-06 07:43:50' and ci.EventCategoryIds in
('2e1ab64c61434df78b7112a2142089bc') ) AND (civ.Published = True)
order by ci.StartDate]
答案 0 :(得分:1)
您无法查询仅保留在InfosetPart
内的属性。如果您需要查询某个零件的某些属性,则需要有一个包含这些属性的支持记录 - 经典方式。