Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edited answer: for the flattened target class C</p> <pre><code>public class C { public string strC1; public string strC2; public string strC3; public int x; public int y; public bool direction; } </code></pre> <p>Just use the SelectMany flattening method and union it a few times...</p> <pre><code>var C1 = A1.SelectMany(p =&gt; p.var1, (p,q) =&gt; new C(){ strC1 = q.strA, strC2 = q.strB, strC3 = q.strC, x = p.x, y = p.y, direction = true } ).Union( A1.SelectMany(p =&gt; p.var2, (p,q) =&gt; new C(){ strC1 = q.strA, strC2 = q.strB, strC3 = q.strC, x = p.x, y = p.y, direction = true }) ).Union( A1.SelectMany(p =&gt; p.var3, (p,q) =&gt; new C(){ strC1 = q.strA, strC2 = q.strB, strC3 = q.strC, x = p.x, y = p.y, direction = false }) ).ToList(); </code></pre> <p>edit2: just realised I repeated the same function 3 times above. A more succinct way of writing this would be:</p> <pre><code>var fn1 = new Func&lt;A, B, C&gt;( (p,q) =&gt; new C(){ strC1 = q.strA, strC2 = q.strB, strC3 = q.strC, x = p.x, y = p.y, direction = !p.var3.Contains(q) }); var C1 = A1.SelectMany(p =&gt; p.var1, fn1 ).Union( A1.SelectMany(p =&gt; p.var2, fn1) ).Union( A1.SelectMany(p =&gt; p.var3, fn1) ).ToList(); </code></pre> <p>edit3 - direction is now false in the above example when coming from the var3 list</p> <p>Heres an article explaining SelectMany a bit more... <a href="http://dotnet.dzone.com/news/selectmany-probably-the-most-p" rel="nofollow">http://dotnet.dzone.com/news/selectmany-probably-the-most-p</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload