Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ayo Adesina 445 posts 1059 karma points
    Oct 02, 2014 @ 11:28
    Ayo Adesina
    0

    Get all property types - Umbraco 7

    Hey guys,

    I'm trying to follow an example, but I think it was written for an older version so I am looking for the umbraco 7 equivalent to this:

    List<PropertyType> types = PropertyType.GetAll().ToList();
    

    Umbraco.Core.Models.PropertyType' does not contain a definition for 'GetAll' - this is the current error I am getting.

  • Sören Deger 733 posts 2844 karma points c-trib
    Oct 02, 2014 @ 11:50
    Sören Deger
    0

    Hi Ayo,

    try this:

    List<PropertyType> types = new List<PropertyType>();

    foreach (var docType in Services.ContentTypeService.GetAllContentTypes())
    {
    foreach (PropertyType prop in Services.ContentTypeService.GetContentType(docType.Id).PropertyTypes)
      {
    types.Add(prop);
      }
    }

    Maybe there is a better solution, but it should works.


    Sören 

Please Sign in or register to post replies

Write your reply to:

Draft