Copied to clipboard

Flag this post as spam?

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


  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jul 22, 2015 @ 14:14
    Martin Griffiths
    0

    How do I use x.GetProperty("property").Value (obj of type IPublishedProperty) in a lambda expr?

    I'm trying to get the correct root document based on culture (en-GB, nl-NL) etc.

    for use in TryFindContent(PublishedContentRequest contentRequest) during a 404.

    Is there an easy way to do this?

    Otherwise I tried to pick the right one from a property set in each root, like this...

    contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First(x => x.DocumentTypeAlias == "root" && x.GetProperty("defaultLanguage").Value == ????

    What do I pass in here when its expecting an object?

    Martin

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 22, 2015 @ 14:27
    Dennis Aaen
    0

    Hi Martin,

    What if you are dong something like this would it works for you.

    contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First(x => x.DocumentTypeAlias == "root" && x.GetPropertyValue<String>("defaultLanguage") == "en") 
    

    So you add the expected return value. like string or int and so on.

    Hope this helps,

    /Dennis

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jul 22, 2015 @ 14:54
    Martin Griffiths
    0

    Hi Dennis

    Yes, normally thats what I would use, but its not available for some reason!

    I was able to cast it this way...

    (bool)x.GetProperty("defaultLanguage").Value == true

    Which seemed to do the trick, although there's no HasValue/HasProperty methods either, which kindof sucks!

    M.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jul 22, 2015 @ 15:09
    Martin Griffiths
    0

    Hi Dennis

    Answered my own question (as I often do). Once I included Umbraco.Web, all of the extension methods appeared... DOH!

    M.

Please Sign in or register to post replies

Write your reply to:

Draft