c# LINQ Dynamic select cross join

71 views Asked by At

Let's say I have the dictionary pinDict[N]. Each element of this dictionary contains different list as string: Dictionary<int, List<string>> pinDict. I want to create the select that contains all combinations with dictionaries' entries.

For instance:

 var s =
          from d1 in pinDict[0]
          from d2 in pinDict[1]
          from d3 in pinDict[2]
          select new { d1, d2, d3 };

It works fine just with predetermined quantity of elements. But I need N elements.

Something like it:

   var s =
              from d1 in pinDict[0]
              from d2 in pinDict[1]
              from d3 in pinDict[2]
              .....................
              from d[i-1] in pinDict[i-1]
              from d[i] in pinDict[i]
              select new { d1, d2, d3, ... d[i-1], d[i] };

How can I create this select? Thanks in advance.

0

There are 0 answers