title: How to compare generics in where clause in linq query
body: <p>I want to compare string of structs for now</p>
  
  <pre><code>public Entity GetByPropertyValue&lt;ValueType&gt;(string propertyName, ValueType value)
  {
      var contact = (from contacts in OrganizationContext.CreateQuery("contact")
                   where (ValueType)contacts[propertyName] == value
                   select contacts).FirstOrDefault();
  
      return contact;
  }
  </code></pre>
  
  <p>but the problem is: </p>
  
  <blockquote>
    <p>Operator '==' cannot be applied to operands of type 'ValueType' and
    'ValueType'</p>
  </blockquote>
  
  <p>If do it otherwise</p>
  
  <pre><code>where object.Equals((ValueType)contacts[propertyName], value)
  </code></pre>
  
  <p>it will not work unfortunately </p>
  
  <blockquote>
    <p>System.NotSupportedException: Invalid 'where' condition. An entity
    member is invoking an invalid property or method.</p>
  </blockquote>