title: EF6 using custom property in a linq query
body: <p>I have a class which has the following property:</p>
  
  <pre><code>[NotMapped]
  public string Key
  {
      get
      {
          return string.Format("{0}_{1}", Process.Name, LocalSequenceNumber);
      }
  }
  </code></pre>
  
  <p>The local sequence number is a computed integer backed by a cache in form of a concurrent dictionary.</p>
  
  <p>I wish to use the Key property above in a LINQ query but get the exception: </p>
  
  <blockquote>
    <p>The specified type member 'Key' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.</p>
  </blockquote>
  
  <p>I understand why I'm getting this error, but I'm not too sure about how to remedy it. Currently, the Key property is providing a nice encapsulation over my class which I don't want to part with. Any suggestions in terms of libraries, or simple patterns to get around this?</p>
  
  <p>Edit: Here's the query which is throwing the exception:</p>
  
  <pre><code>db.Cars.SingleOrDefault(c =&gt; c.Id == id &amp;&amp; c.Key == key);
  </code></pre>