How do I query for IPublishedContent without UmbracoContext?
I've been working through introducing some parallelism to (custom-built) long running tasks (mainly in the backoffice - these are mainly tools that I've built to automate adding content to the system, etc); I've been simply using Task.Run( () => { ... } );
I know that I can get access to the services via ApplicationContext.Current.Services; however I've not figured out how to query for IPublishedContent - which as far as I am aware is done via the UmbracoHelper which needs an UmbracoContext. I could probably do what I need using the ContentService but that feels a little wrong as what I'm really wanting to be doing is to query for information in a read-only manner.
Is there currently a way to do this via the available APIs?
Why you don't want to use Services? Services are for backend, IPublishedContent for front-end, but I agree with you that it makes sense to use IPublishedContent for read-only data.
You can create context object and use it:
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var frontPage = umbracoHelper.TypedContent(id);
How do I query for IPublishedContent without UmbracoContext?
I've been working through introducing some parallelism to (custom-built) long running tasks (mainly in the backoffice - these are mainly tools that I've built to automate adding content to the system, etc); I've been simply using Task.Run( () => { ... } );
I know that I can get access to the services via ApplicationContext.Current.Services; however I've not figured out how to query for IPublishedContent - which as far as I am aware is done via the UmbracoHelper which needs an UmbracoContext. I could probably do what I need using the ContentService but that feels a little wrong as what I'm really wanting to be doing is to query for information in a read-only manner.
Is there currently a way to do this via the available APIs?
Hi Joseph,
Why you don't want to use Services? Services are for backend, IPublishedContent for front-end, but I agree with you that it makes sense to use IPublishedContent for read-only data.
You can create context object and use it:
Thanks, Alex
is working on a reply...