if I have a udi with the following value "{umb://any-guid/f91a88d2d4114771ad29afb666eb189c}". Take note of the any-guid because it is of importance and beyond my control (So I can't just change it).
The exception message in the 2nd option is "Udi entity type must be "document"." What is the difference between going through the UmbracoHelper and via the ContentService?
UmbracoHelper uses the IPublishedContentQuery under the hood, but if I try injecting that, I just get a LightInject-error and Umbraco won't even boot.
Injecting the UmbracoHelper also gives me the same error.
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.Runtime.<>c.<Compose>b__0_6(IFactory factory) in d:\a\1\s\src\Umbraco.Web\Runtime\WebInitialComposer.cs:116
If I cannot inject UmbracoHelper or the IPublishedContentQuery, but I do have the IUmbracoContextFactory, where do I find a Content.GetById that will yield result?
So the difference between the ContentService and the UmbracoHelper is that you can get the IPublishedContent version from the content cache in the UmbracoHelper and that the ContentService gets a IContent version from the database directly.
The reason why you can't inject the UmbracoHelper is because it can't create the helper.In order to create the object it needs other objects, but those objects aren't there at the time of startup.
Dependency Injection and IPublishedContentQuery
Hi,
if I have a udi with the following value "{umb://any-guid/f91a88d2d4114771ad29afb666eb189c}". Take note of the any-guid because it is of importance and beyond my control (So I can't just change it).
I can retrieve the document in several ways
The exception message in the 2nd option is "Udi entity type must be "document"." What is the difference between going through the UmbracoHelper and via the ContentService?
UmbracoHelper uses the IPublishedContentQuery under the hood, but if I try injecting that, I just get a LightInject-error and Umbraco won't even boot. Injecting the UmbracoHelper also gives me the same error.
If I cannot inject UmbracoHelper or the IPublishedContentQuery, but I do have the IUmbracoContextFactory, where do I find a Content.GetById that will yield result?
Any insight?
Hi,
So the difference between the ContentService and the UmbracoHelper is that you can get the IPublishedContent version from the content cache in the UmbracoHelper and that the ContentService gets a IContent version from the database directly.
The reason why you can't inject the UmbracoHelper is because it can't create the helper.In order to create the object it needs other objects, but those objects aren't there at the time of startup.
Try adding a Minimum Runtime level of Run and then inject the Helper. https://our.umbraco.com/Documentation/Implementation/Composing/#runtimelevel
-Joep
is working on a reply...