Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Aug 31, 2016 @ 07:57
    Jeroen Breuer
    0

    Get raw value instead of the converted value

    Hello,

    I'm using the Umbraco Core Property Value Converters. So for MNTP I always get the IEnumerable with IPublishedContent. I would like to only get the ids. I can't do the following: this.GetPropertyValue<IEnumerable<IPublishedContent>>("elements").Select(x => x.Id)

    Because this will go through the converter which means they've already been converted to IPublishedContent and I don't want that because it's bad for performance.

    Can I get the raw value for a specific property while not going through the converter?

    Jeroen

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Aug 31, 2016 @ 08:21
    Dan Diplo
    101

    Yep, you can do:

    this.GetProperty("elements").DataValue
    

    This will return the raw value. In the case of an MNTP it depends on the format of how you saved it, but usually this would be CSV so you can cast to string and then do a String.Split, something like:

    this.GetProperty("elements").DataValue.ToString().Split(',').Select(n => Convert.ToInt32(n));
    
  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Aug 31, 2016 @ 10:32
    Jeroen Breuer
    0

    Thanks. It works perfect!

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 31, 2016 @ 08:41
    Jeavon Leopold
    0

    Yes exactly what Dan says.

  • 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