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 419 posts 1001 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 726 posts 2833 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 

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies