Umbraco.ContentQuery.Search replacement for controller
Hi folks
After upgrade of a project my search controller stopped working ( UmbracoApiController ) since ContentQuery is obsolete.
var results = Umbraco.ContentQuery.Search(term);
It should be replaced by IPublishedContentQuery but I can't figure out how to access this easily in a controller. There are a some examples on how to do it in a view out there - but not in a controller like this.
Umbraco.ContentQuery.Search replacement for controller
Hi folks
After upgrade of a project my search controller stopped working ( UmbracoApiController ) since ContentQuery is obsolete.
It should be replaced by IPublishedContentQuery but I can't figure out how to access this easily in a controller. There are a some examples on how to do it in a view out there - but not in a controller like this.
Hi Ulrik,
You need to use constructor injection on the ApiController as below
You can also access this using
Current.PublishedContentQuery.Search(term)
However where possible using the injected method is preferable.Hope this helps
Matt
Thanks Matt - it works :)
However I realized that my previous code wasn't the issue but something further down in the code.
But hey ... with your code I'm more ready for future upgrades if the previous obsolete classes gets removed :)
is working on a reply...