Copied to clipboard

Flag this post as spam?

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


  • Tom Madden 252 posts 454 karma points MVP 4x c-trib
    Aug 26, 2015 @ 10:30
    Tom Madden
    0

    item.GetValue throws and exception if the property doesn't exist

    it would be better if GetValue returned a null if the property didn't exist. I had to add a try catch around this call to get round this

    You can't check for it being null or empty because it doesn't get that far

    e.g. this doesn't help

    var item = Model.Items.ElementAt(0);
    var foo = String.IsNullOrEmpty(item.GetValue<string>("bar")) ? item.GetValue<string>("bar") : "";
    

    many thanks

    Tom

  • Dan Evans 629 posts 1016 karma points
    Sep 23, 2015 @ 10:10
    Dan Evans
    0

    Did you ever solve this?

  • Tom Madden 252 posts 454 karma points MVP 4x c-trib
    Sep 23, 2015 @ 10:31
    Tom Madden
    0

    Hi,

    this is fixed in the source code on Github from a commit on 24th July, I grabbed it from there and it did solve the problem.

    HTH

    t

  • Dan Evans 629 posts 1016 karma points
    Sep 23, 2015 @ 10:46
    Dan Evans
    0

    Any idea when this will be released as an final update?

  • Tom Brian Stegmann 20 posts 135 karma points
    Aug 11, 2023 @ 08:42
    Tom Brian Stegmann
    0

    Hi there,

    I know that this question is pretty ancient by now, but here is my suggested and very simple solution which has resolved it for me when working with legacy Umbraco versions. 🙂 Hope it helps.

    Best, Tom

     public bool LeBlenderHasValue(
        string fieldName, 
        Lecoati.LeBlender.Extension.Models.LeBlenderValue leblenderValue)
    {
        try
        {
            var testValue = leblenderValue.GetValue(fieldName);
            return true;
        }
        catch (Exception)
        {
            return false;
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft