Note that there are some explanatory texts on larger screens.

plurals
  1. POselect from Dictionary finds value but select from ConcurrentDictionary does not
    primarykey
    data
    text
    <p>Today i was doing some tests with the ConcurrentDictionary and Dictionary:</p> <pre><code>class MyTest { public int Row { get; private set; } public int Col { get; private set; } public string Value { get; private set; } public MyTest(int row, int col, string value) { this.Col = col; this.Row = row; this.Value = value; } public override bool Equals(object obj) { MyTest other = obj as MyTest; return base.Equals(other); } public override int GetHashCode() { return (Col.GetHashCode() ^ Row.GetHashCode() ^ Value.GetHashCode()); } } </code></pre> <p>Using the Entity above i created and filled a ConcurrentDictionary and a Dictionary and tried the code below:</p> <pre><code> ConcurrentDictionary&lt;MyTest, List&lt;MyTest&gt;&gt; _test = new ConcurrentDictionary&lt;MyTest, List&lt;MyTest&gt;&gt;(); Dictionary&lt;MyTest, List&lt;MyTest&gt;&gt; _test2 = new Dictionary&lt;MyTest, List&lt;MyTest&gt;&gt;(); MyTest dunno = _test.Values.AsParallel().Select(x =&gt; x.Find(a =&gt; a.Col == 1 &amp;&amp; a.Row == 1)).FirstOrDefault(); MyTest dunno2 = _test2.Values.AsParallel().Select(x =&gt; x.Find(a =&gt; a.Col == 1 &amp;&amp; a.Row == 1)).FirstOrDefault(); </code></pre> <p>The first one returns the value but the second one not, what am i doing wrong?</p> <p>This is the code used to add the values:</p> <pre><code> _test.AddOrUpdate(cell10, new List&lt;MyTest&gt; { new MyTest(1, 1, "ovpSOMEVALUEValue"), new MyTest(1, 2, "ocpSOMEVALUEValue") }, (key, value) =&gt; value = new List&lt;MyTest&gt;()); _test2.Add(cell10, new List&lt;MyTest&gt; { new MyTest(1, 1, "ovpSOMEVALUEValue"), new MyTest(1, 2, "ocpSOMEVALUEValue") } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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