title: Lambda way to fill the value field in the ToDictionary() method?
body: <p>I have two IEnumerable</p>
  
  <pre><code>IEnumerable&lt;MyObject&gt; allowedObjects = MyService.GetAllowedObjects();
  IEnumerable&lt;MyOBject&gt; preferedObjects = MyService.GetPreferedObjects();
  </code></pre>
  
  <p>We can safely assume that preferedObjects will always be a subset of allowedObjects.<br>
  I want to create an <code>IDictionary&lt;MyObject, bool&gt;</code>. Objects where the key is the set of MyObjects from the allowedObjects and the bool is true if the MyObject instance was also in the preferedObjects enumerable.</p>
  
  <p>I can do this by enumerating them and adding them one by one, but I would like to be able to do something like this:</p>
  
  <pre><code>IDictionary&lt;MyObject, bool&gt; selectedObjects = allowedObjects
      .ToDictionary(o =&gt; new KeyValuePair&lt;MyObject, bool&gt;()
          { Key = q,
            Value = preferedObjects.Any(q)
          }
       );
  </code></pre>
  
  <p><strong>UPDATE</strong><br>
  Exchanged Contains with Any;
  The solution that is suggested most was what I tried first, but it isn't accepted for some reason:</p>
  
  <pre><code>IDictionary&lt;MyObject, bool&gt; selectedObjects = allowedObjects
      .ToDictionary&lt;MyObject, bool&gt;(o =&gt; o, preferedObjects.Any(o));
  </code></pre>
  
  <p>Visual studio says the first method does not return a bool. Which is true, but mainly because a bool would not be the correct result to start with...<br>
  And then it says it cannot infere the type of the second lambda...<br>
  As you can see I tried to explicitly define the types to help the inference, but it doesn't solve a thing..</p>
  
  <p>Suggestions?</p>
  
  <p>Disclaimer: names and code are snippyfied to keep the focus where it should be</p>