我创建了一个新查询,当我尝试预览时,我收到以下错误。
我按照此链接创建了一个内容类型Book并向其添加了内容部分产品。
http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-5
无法执行查询
[select distinct TOP(@ p0)contentite0_.Id as col_0_0_ from Orchard_Framework_ContentItemVersionRecord contentite0_ inner join Orchard_Framework_ContentItemRecord contentite1_ on contentite0_.ContentItemRecord_id = contentite1_.Id inner join Customer_ProductPartRecord productpar2_ on contentite1_.Id = productpar2_.Id where contentite0_.Published = 1 order by contentite0_.Id]
[SQL:选择distinct TOP(@ p0)contentite0_.Id as col_0_0_ from Orchard_Framework_ContentItemVersionRecord contentite0_ inner join Orchard_Framework_ContentItemRecord contentite1_ on contentite0_.ContentItemRecord_id = contentite1_.Id inner join Customer_ProductPartRecord productpar2_ on contentite1_.Id = productpar2_.Id where contentite0_.Published = 1 by orderite0_.Id]
**ProductPartFilter.cs**
using Orchard.Localization;
using Orchard.Projections;
using Orchard.Projections.Descriptors.Filter;
using Skywalker.Webshop.Models;
using IFilterProvider = Orchard.Projections.Services.IFilterProvider;
namespace Skywalker.Webshop.Filters
{
public class ProductPartFilter : IFilterProvider
{
public Localizer T { get; set; }
public ProductPartFilter()
{
T = NullLocalizer.Instance;
}
public void Describe(DescribeFilterContext describe)
{
describe.For(
"Content", // The category of this filter
T("Content"), // The name of the filter (not used in 1.4)
T("Content")) // The description of the filter (not used in 1.4)
// Defines the actual filter (we could define multiple filters using the fluent syntax)
.Element(
"ProductParts", // Type of the element
T("Product Parts"), // Name of the element
T("Product parts"), // Description of the element
ApplyFilter, // Delegate to a method that performs the actual filtering for this element
DisplayFilter // Delegate to a method that returns a descriptive string for this element
);
}
private void ApplyFilter(FilterContext context)
{
// Set the Query property of the context parameter to any IHqlQuery. In our case, we use a default query
// and narrow it down by joining with the ProductPartRecord.
context.Query = context.Query.Join(x => x.ContentPartRecord(typeof(ProductPartRecord)));
}
private LocalizedString DisplayFilter(FilterContext context)
{
return T("Content with ProductPart");
}
}
}