Copied to clipboard

Flag this post as spam?

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


  • Marky 26 posts 65 karma points
    1 week ago
    Marky
    0

    How to get property values from multiple Ids

    Hi All,

    I have a compare function which has a 3 items to compare.

    My problem is how can I get their properties with their corresponding ID.

    /// Umbraco/Api/Search/ComparisonKeyValues?ids=2874,2875,2876
    public List<KeyValuePair<int, string>> ComparisonKeyValues(string ids)
    {
        // what should I put here...
    }
    

    Or what shoul I put after public ?

    Any help for this, thanks in advance.

    I'm new in C# and Umbraco

    Thanks

    Marky

  • Marky 26 posts 65 karma points
    1 week ago
    Marky
    0

    What I've done is...

    ///umbraco/Api/search/ComparisonKeyValues?ids=2874,2875,2876
    public List<KeyValuePair<int, string>> ComparisonKeyValues(string ids)
    {
        if (!string.IsNullOrEmpty(ids))
        {
            var nodes = ids.Split(',').ToList().TypedContentList();
            return nodes.Select(x => new KeyValuePair<int, string>(x.Id, x.GetPropertyValue<string>("title"))).ToList();
        }
        return new List<KeyValuePair<int, string>>();
    }
    

    But I only get the ID & title..

    I want also get the productImage

    How can I do this?

    Any help?

    Thanks

    Marky

  • Dirk De Grave 4518 posts 5876 karma points MVP 3x admin
    1 week ago
Please Sign in or register to post replies

Write your reply to:

Draft