Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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,
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:
IEnumerable<IContent> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent> filter, Ordering ordering = null);
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
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!
public interface IContentTypeService : IContentTypeBaseService<IContentType>, IContentTypeBaseService, IService
IEnumerable<string> GetAllContentTypeAliases(params Guid objectTypes);
IEnumerable<int> GetAllContentTypeIds(string aliases);
If you want an explaination of the methods, you can look in the source code, where the comments are pretty good:
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.
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...
Write your reply to:
Image will be uploaded when post is submitted