Hi, I am new to Umbraco development, and I am stuck because GetContentOfContentType, GetDescendants, and many other documented ContentService methods are missing from the API. I have both installed from NuGet, and built from source. What am I doing wrong? TIA,
This version has only just been released (this week), and it contains a large number of breaking changes from V7. Sadly not all of these are documented yet!
This would explain why you aren't seeing the methods available on the ContentService that are documented as these have largely been renamed for V8.
So I think you should be able to use:
IEnumerable<IContent> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent> filter, Ordering ordering = null);
and
IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent> filter = null, Ordering ordering = null);
There is also a 'count descendants' property:
int CountDescendants(int parentId, string documentTypeAlias = null);
Thanks Marc, yes it’s v8. I had already figured out some of the new methods (e.g. ContentTypeService.Get()), and I’d noticed the ones you mention, but as they are undocumented I’m not sure what they mean and what arguments to pass. But now I know I’m not overlooking something very obvious. I’ll see how far I can get without the doc.
If your using Visual Studio, you can usually right click the Service
eg Services.ContentService
and select GoToDefinition you'll get from MetaData a list of the Services, then using the same trick with the interface eg right click IContentService or IContentTypeService, you'll get all their methods, and what parameters and types need to be passed to them.
it's not documentation but at least you can see what's there!
The GetPagedOfType is pretty annoying given sometimes you'd want to get all of them so does that mean it'd be perfectly ok to call it with int.MaxValue as your page size :)
Methods missing from ContentService API
Hi, I am new to Umbraco development, and I am stuck because GetContentOfContentType, GetDescendants, and many other documented ContentService methods are missing from the API. I have both installed from NuGet, and built from source. What am I doing wrong? TIA,
Hi David
Are you using v8 of Umbraco?
This version has only just been released (this week), and it contains a large number of breaking changes from V7. Sadly not all of these are documented yet!
This would explain why you aren't seeing the methods available on the ContentService that are documented as these have largely been renamed for V8.
So I think you should be able to use:
and
There is also a 'count descendants' property:
regards
Marc
Thanks Marc, yes it’s v8. I had already figured out some of the new methods (e.g. ContentTypeService.Get()), and I’d noticed the ones you mention, but as they are undocumented I’m not sure what they mean and what arguments to pass. But now I know I’m not overlooking something very obvious. I’ll see how far I can get without the doc.
Hi David
If your using Visual Studio, you can usually right click the Service
eg Services.ContentService
and select GoToDefinition you'll get from MetaData a list of the Services, then using the same trick with the interface eg right click IContentService or IContentTypeService, you'll get all their methods, and what parameters and types need to be passed to them.
it's not documentation but at least you can see what's there!
eg
If you want an explaination of the methods, you can look in the source code, where the comments are pretty good:
https://github.com/umbraco/Umbraco-CMS/blob/91c52cffc8b7c70dc956f6c6610460be2d1adc51/src/Umbraco.Core/Services/Implement/ContentTypeService.cs
the comments will be used to generate the auto-documentation pages - but I understand it's not quite ready to switch over to be the V8 docs yet.
regards
Marc
Really great Marc, that’s much more of an answer than I could have hoped for. And yes I’ve been able to use the new methods. Thanks again.
The GetPagedOfType is pretty annoying given sometimes you'd want to get all of them so does that mean it'd be perfectly ok to call it with int.MaxValue as your page size :)
is working on a reply...