Copied to clipboard

Flag this post as spam?

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


  • Sonja 132 posts 620 karma points
    Nov 27, 2019 @ 06:24
    Sonja
    0

    multinode treepicker in linq

    Hi, I have document type Deal having multinode treepicker named device that is picking nodes with type Device. The Device nodes all have Id that's the umbraco Id.

    Now I have integer value "did". I need to select all the Deals that have once selected in the multinode treepicker the node with the Id equals to did.

    selection = selection.Where(x => (((Deal)x).Device != null) && ...); //The problem is the code where the ... are.
    

    Please advice what do I put in the ...

  • Sonja 132 posts 620 karma points
    Nov 28, 2019 @ 10:23
    Sonja
    0

    any updates on my problem?

  • Joep 95 posts 697 karma points
    Nov 28, 2019 @ 10:30
    Joep
    1

    If I understand your question correctly. You want to get all "selections" where the Id matches "did"?selection = selection.Where(x => ((Deal)x).Device != null && x.Id == did

    The above should be your answer if you are using the Multinode.Treepicker. But if you are using the Multinode.Treepicker2 you need to convert the Udi to an Id first.

  • Sonja 132 posts 620 karma points
    Nov 28, 2019 @ 10:52
    Sonja
    0

    No Joep, this was not my question. did is the Id of a Device. selection is a List of Deal. 1 selection can have multiple devices.
    If it was content picker it would have been selection = selection.Where(x => ((Deal)x).Device != null && (Device)((Deal)x).Device.Id== did)) and this works with content picker. But in this case I have multinode treepicker. And yes it is a Multinode.Treepicker2

  • Joep 95 posts 697 karma points
    Nov 28, 2019 @ 11:05
    Joep
    100

    So something like this? selection = selection.Where(x => ((Deal)x).Device != null && x.Device.Any(d => d.Id == did)

Please Sign in or register to post replies

Write your reply to:

Draft