Search code examples
c#umbraco7

Multinode Treepicker in Umbraco containing value in id


I have Deal Document Type that contains Multinode Treepicker named device. This contains multiple record of the document type Device. Now every device has its Id defined by Umbraco. I have one integer value did and the list of deals named dealSelection.

I need to select all the Deals from dealSelection that conmtain the value did in Deal.device. Here is the code:

var did = 1010;
dealSelection = dealSelection.Where(x => ((((Deal)x).Device != null) && (/*PLEASE HELP WHAT TO PUT HERE*/));

Please help how to do the Linq so that I have in dealSelection all the deals having the device with id=did. I'm using Umbraco 7

Thanks


Solution

  • I'm going to answer my question so that others that have same problem as me can get the answer:

    var did = 1010;
    dealSelection = dealSelection.Where(x => ((((Deal)x).Device != null) && (((Deal)x).Device.Any(d => d.Id == did)));