Note that there are some explanatory texts on larger screens.

plurals
  1. POsee if any item exists in any list item
    primarykey
    data
    text
    <p><strong>i have a list</strong></p> <pre><code> List&lt;FirstIterationCapacitors&gt; FirstIteration = new List&lt;FirstIterationCapacitors&gt;(); // A set of Solution capacitors object </code></pre> <p><strong>Here is it's class</strong></p> <pre><code>class FirstIterationCapacitors { public int Iteration { get; set; } public int CapacitorALocation { get; set; } public int CapacitorBLocation { get; set; } public int CapacitorCLocation { get; set; } } </code></pre> <p><strong>Now i have a second list</strong></p> <pre><code> List&lt;PossibleSolutionCapacitors&gt; PossibleSolution = new List&lt;PossibleSolutionCapacitors&gt;(); // Possible Solution capacitors object </code></pre> <p><strong>here is its class</strong></p> <pre><code> class PossibleSolutionCapacitors { public int CapacitorALocation { get; set; } public int CapacitorBLocation { get; set; } public int CapacitorCLocation { get; set; } } </code></pre> <p>For a given row (i.e for row 2) in PossibleSolution i need to see if </p> <ol> <li>PossibleSolution.CapacitorALocation does not exist in FirstIteration.CapacitorALocation (that equal to iteration X) or FirstIteration.CapacitorBLocation (that equal to iteration X) or FirstIteration.CapacitorCLocation (that equal to iteration X)</li> </ol> <p>OR</p> <ol> <li>PossibleSolution.CapacitorBLocation does not exist in FirstIteration.CapacitorALocation (that equal to iteration X) or FirstIteration.CapacitorBLocation (that equal to iteration X) or FirstIteration.CapacitorCLocation (that equal to iteration X)</li> </ol> <p>OR</p> <ol> <li>PossibleSolution.CapacitorCLocation does not exist in FirstIteration.CapacitorALocation (that equal to iteration X) or FirstIteration.CapacitorBLocation (that equal to iteration X) or FirstIteration.CapacitorCLocation (that equal to iteration X)</li> </ol> <p>ideally a boolean stating true false if the condition is true/false</p> <p><strong>Here is what i have tried so far but it is not working</strong></p> <pre><code>int D = 4; // The row i care about int E = PossibleSolution[D].CapacitorALocation; int F = PossibleSolution[D].CapacitorBLocation; int G = PossibleSolution[D].CapacitorCLocation; var fixedSet = new HashSet&lt;int&gt;() {E}; if (!FirstIteration.Any(x =&gt; fixedSet.SetEquals(new[] { x.CapacitorALocation, x.CapacitorBLocation, x.CapacitorCLocation }))) { fixedSet = new HashSet&lt;int&gt;() {F}; if (!FirstIteration.Any(x =&gt; fixedSet.SetEquals(new[] { x.CapacitorALocation, x.CapacitorBLocation, x.CapacitorCLocation }))) { fixedSet = new HashSet&lt;int&gt;() {G}; if (!FirstIteration.Any(x =&gt; fixedSet.SetEquals(new[] { x.CapacitorALocation, x.CapacitorBLocation, x.CapacitorCLocation }))) { //Match does not exist so do some real work here ...... } } } </code></pre> <p>thanks, damo</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.
 

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