Orchardcms 我在Orchard CMS中尝试预览查询时遇到此错误
我创建了一个新的查询,当我尝试预览它时,我得到以下错误 我按照这个链接创建了一本内容类型书,并将内容部分产品添加到其中 无法执行查询 [选择不同的顶部(@p0)contentite0.Id作为col\u 0\u 0\u来自Orchard\u Framework\u ContentItemVersionRecord contentite0\u内部加入Orchard\u Framework\u contentiterecord contentite0\u上的contentite0.ContentItemRecord contentite1\u.Id=contentite1\u.Id=ProductPartRecord productpar2\u.Id其中contentite0\u.Published=1按contentite0.Id订购] [SQL:选择不同的顶部(@p0)contentite0.Id作为col\u 0\u 0\u来自Orchard\u Framework\u ContentItemVersionRecord contentite0\u内部加入Orchard\u Framework\u contentiterecord contentite0\u上的contentite0.ContentItemRecord contentite1\u.Id=contentite1\u.Id=ProductPartRecord productpar2\u.Id其中contentite0\u.Published=1按contentite0.Id订购]Orchardcms 我在Orchard CMS中尝试预览查询时遇到此错误,orchardcms,orchardcms-1.7,Orchardcms,Orchardcms 1.7,我创建了一个新的查询,当我尝试预览它时,我得到以下错误 我按照这个链接创建了一本内容类型书,并将内容部分产品添加到其中 无法执行查询 [选择不同的顶部(@p0)contentite0.Id作为col\u 0\u 0\u来自Orchard\u Framework\u ContentItemVersionRecord contentite0\u内部加入Orchard\u Framework\u contentiterecord contentite0\u上的contentite0.ContentI
**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");
}
}
}
为什么需要为此创建一个过滤器?已存在用于投影的内容类型筛选器。另外,您能提供完整的错误消息吗?我注意到,如果我使用Orchard管理选项创建内容部分和内容类型,包括查询在内的一切都可以正常工作。但是,如果我使用模块(代码)创建内容部分和内容类型,它永远不会工作。所以,如果我创建一个由模块创建的内容查询,它只显示记录的日期时间,但如果我创建一个由管理员选项创建的内容类型查询,它工作正常,并显示记录的所有属性。这并不意味着你应该创建一个不必要的过滤器,这意味着你的迁移可能有问题。请显示您的迁移。驱动程序和placement.info文件中存在问题,已解决。非常感谢你的帮助