This project is read-only.

create a query part via code

Topics: Customizing Orchard, Troubleshooting, Writing modules
Nov 28, 2014 at 1:49 PM
hi guys,I am creating a custom module in Orchard , I would like to create a query programmatically.
string  queryName= "Product";
var item = _orchardServices.ContentManager.New("Query");
item.As<TitlePart>().Title =queryName;
_orchardServices.ContentManager.Create(item, VersionOptions.Draft);
if (!item.Has<IPublishingControlAspect>() && !item.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)

var queryPart = item.As<QueryPart>();
queryPart.ContentItem.ContentType = queryName;
string desc =" filter for the query";
string contentType = "CommonPart.ChannelID.";
var filterGroupRecord = new FilterGroupRecord();
var filterRecord = new FilterRecord()
    Category = "CommonPartContentFields",
    Type = contentType,
    Position = 0,
filterRecord.State = "<Form><Description>" + desc + "</Description><Operator>Equals</Operator><Value>ChannelId</Value></Form>";
queryPart.FilterGroups.Insert(0, filterGroupRecord);
the problem is that:I want set a filters of the query,not a filters group. could you tell me how to improve my code?
Nov 28, 2014 at 6:46 PM
If you cross post, please provide a link. Otherwise people might still be spending time on one site while your question might be answered on the other site. And that is a waste of people's time.