title: Lambda expression with .Where clause using Contains
body: <p>When connecting to CRM 2013 is there a smart way to create a lambda expression that gets the entities who's GUID are in a List.</p>
  
  <p>This code breaks on the Where clause and gives the error: </p>
  
  <blockquote>
    <p>Invalid 'where' condition. An entity member is invoking an invalid property or method.</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>    private List&lt;UserInformationProxy&gt; GetContactsFromGuidList(List&lt;Guid&gt; contactList)
      {
          var result = _serviceContext.ContactSet
              .Where(x=&gt; contactList.Contains((Guid) x.ContactId)) // this line breaks
              .Select(x =&gt; new UserInformationProxy()
              {
                  FullName = x.FullName,
                  Id = x.ContactId
              })
              .Distinct()
              .ToList&lt;UserInformationProxy&gt;();
  
          return result;
      }
  
      // return class
      public class UserInformationProxy
      {
          public Guid? Id { get; set; }
          public string FullName { get; set; }
          public string DomainName { get; set; }
      }
  </code></pre>
  
  <p>Currently I'm solving this by getting all the contacts from the ContactSet and sorting out the ones I want with a loop in my code. This works, but is quite slow as I need to get all 10000 contacts instead of sending the Guids of the 40 Im actually interested in to the SQL server.</p>