Ticket (Solved)

Adding Query Programmatically - what am I doing wrong?

Hi All, I've been looking at the Orchard DB and working backwards to good effect until now. When the following code runs, the query doesn't display in the dashboard, but upon checking the tables in the DB - all seems to be populated correctly? Can anyone see what I'm doing wrong / have missed? Thanks for your efforts, PP

        public int UpdateFrom3()
        // Create the Queries to sort the individual websites via their pages/taxonomy:
        var websiteQuery = _contentManager.New("Query");
        websiteQuery.As<TitlePart>().Title = "cbbhQuery";
        websiteQuery.As<QueryPart>().ContentItem.ContentType = "cbbhQuery";
        var filterGroupRecord = new FilterGroupRecord();
        var filterRecord = new FilterRecord()
            Category = "Taxonomy",
            Type = "HasTerms",
            Description = "return all foo pages",
            State = "<Form><Description>return all foo pages</Description><TermIds>13</TermIds><Operator>0</Operator></Form>",
            Position = 0

        filterGroupRecord.Filters.Insert(0, filterRecord);
        websiteQuery.As<QueryPart>().FilterGroups.Insert(0, filterGroupRecord);

        _contentManager.Create(websiteQuery, VersionOptions.Published);
        return 4;

Re: Adding Query Programmatically - what am I doing wrong?

hmm, changed top line to: **var websiteQuery = _contentManager.Create("Query");** and obviously got rid of the third last line: **_contentManager.Create(websiteQuery, V....** and it now works - thanks PP

Wednesday, January 20, 2016 7:24:05 AM bypigpen
  • pigpen
  • Lv. 02 Rookie
  • Total EXP: 58

Post a reply

You need to be signed in to post a reply.

Sign In