Does LINQ contain every item from all groups?

I have this matchd condition:

            var matchConditions = new long[][] 
                { 
                    new long[] { 109, 145 }, //color Id
                    new long[] { 202 }, // province Id
                    new long[] { 303, 309, 317, 318 }, //options Id
                };

each of them is the id of another group, for example, the first nested array for color.
and I need to know which products match the color ID 109 or 145, the second one for something else.
I want me to get all the products that match any element of each group,

{color 109 or 145 - and - area 202 - and - option 303 or 309 or 317 or 318}

I tried:

matchConditions.ToList().ForEach(x => x.Any(j => adAdFields.Select(co => co.listFieldId).Contains(j)))

and

matchConditions.All(x => x.Any(j => adAdFields.Select(co => co.listFieldId).Contains(j)))

but none of them work

EDIT: I used to have this request:

var adsWithRelevantadFields =
from adField in cwContext.tblAdFields
join ads in cwContext.tblAds on adField.adId equals ads.id
where (prvId == 0 && ads.tabId == tabId) ||
(prvId != 0 & ctsId.Value == 0 && ads.provinceId == prvId & ads.tabId == tabId) ||
(prvId != 0 & ctsId.Value > 0 && ads.provinceId == prvId & ads.cityId == ctsId.Value & ads.tabId == tabId)
where ads.endDate >= theToDay
where ads.conditionId == 1
where ads.payed == true                                                       
group adField by adField.adId into adAdFields                                 
where searchIds.All(i => adAdFields.Select(co => co.listFieldId).Contains(i))

, , , , "& &" , .

EDIT2
, (, , , ,....) , , (productId, attributeId), , , (1 109 - 1,202 - 1, 303...) (2,109 - 2,202-2,318...)...

( ), , grop:
{ 109 145 - - 202 - - 303 309 317 318}

+3
3

- ?

adAdFields.Where(x => matchConditions[0].Contains(x.colorId)
                  &&  matchConditions[1].Contains(x.provinceId)
                  && matchConditions[2].Contains(x.optionsId))
          .ToList();
+3

, , - , .

:

class Program
{
    static void Main(string[] args)
    {
        var adAdFields = new List<AdAdField>
        {
            new AdAdField {colorId = 109, optionsId = 303, provinceId = 202},
            new AdAdField {colorId = 145, optionsId = 309, provinceId = 2},
            new AdAdField {colorId = 3, optionsId = 317, provinceId = 3},
            new AdAdField {colorId = 4, optionsId = 318, provinceId = 4}
        }.AsQueryable();

        var matchConditions = new long[][] 
            { 
                new long[] { 109, 145 }, //color Id
                new long[] { 202 }, // province Id
                new long[] { 303, 309, 317, 318 }, //options Id
            };

        var result1 = adAdFields.Where(x => matchConditions[0].Contains(x.colorId)
                              && matchConditions[1].Contains(x.provinceId)
                              && matchConditions[2].Contains(x.optionsId)).ToList();

        var query = adAdFields;

        if (matchConditions[0].Length > 0)
            query = query.Where(x => matchConditions[0].Contains(x.colorId));

        if (matchConditions[1].Length > 0)
            query = query.Where(x => matchConditions[1].Contains(x.provinceId));

        if (matchConditions[2].Length > 0)
            query = query.Where(x => matchConditions[2].Contains(x.optionsId));
        //below will be other possible conditions....


        var result2 = query.ToList();
        //result2 and result1 ARE SAME!!!
    }
}

public class AdAdField
{
    public int colorId { get; set; }
    public int provinceId { get; set; }
    public int optionsId { get; set; }
}

IQueriable , .ToList(), orm sql. .

+1

All Articles