Using filter param of content service GetPagedChildren
I am using the GetPagedChildren method of the contentservice backoffice api. I want to return my paged children only where a property of that object is equal to a certain value, in this case where the Property "Active" is true.
I see that the last param of this method is called filter so I do this:
.contentService.GetPagedChildren(parentId, pageIndex, pageSize, out total, filter: "Active == true")
But passing "Active == true" doesn't work - no results come back.
Is this correct use and syntax for filter param?
Can I use it like this?
if (filter.IsNullOrWhiteSpace() == false)
{
filterQuery = Query<IContent>.Builder.Where(x =>x.Name.Contains(filter));
}
So it looks like it's doing more of a substring match on the value of name - so it's more of a "search term" rather than a conditional filter, I think.
Using filter param of content service GetPagedChildren
I am using the GetPagedChildren method of the contentservice backoffice api. I want to return my paged children only where a property of that object is equal to a certain value, in this case where the Property "Active" is true.
I see that the last param of this method is called filter so I do this:
.contentService.GetPagedChildren(parentId, pageIndex, pageSize, out total, filter: "Active == true")
But passing "Active == true" doesn't work - no results come back. Is this correct use and syntax for filter param? Can I use it like this?
You can see how it works from the source code:
So it looks like it's doing more of a substring match on the value of name - so it's more of a "search term" rather than a conditional filter, I think.
Hi Robert,
Is this code for rendering information on the front end ?
Than I would strongly suggest you not to use the content service.
This hits the Umbraco Database and bypasses the cache, which can lead to perfomance problems.
If it is for rendering on the front end have a look at the documentation here : https://our.umbraco.org/documentation/Reference/Querying/
Dave
Unfortunately it's for a webapi and I need to return whats in the db, published or not.
Okay keep in mind.
That this will also return content that is not published yet.
But I used published content in a web api without problems.
Dave
is working on a reply...