title: Query unmapped class member
body: <p>I have my class <code>GreenGroup</code> which inherits from abstract <code>Group</code>. <code>GreenGroup</code> has an unmapped property <code>State</code> that is defined in a partial class.</p>
  
  <p>I have a method <code>GetGreenGroups(GroupFilter filter)</code> that should return a list of GreenGroup objects where the State == filter.State.</p>
  
  <pre><code>public List&lt;GreenGroup&gt; GetGreenGroups(GroupFilter filter)
  {
      IQueryable&lt;VirtualMachineInfo&gt; result = GetAllGroupsInternal(userContext);
  
      if(filter.OwnerId != Guid.Empty)
      {
          result = result.Where(g =&gt; g.OwnerID == filter.OwnerId);
      }
  
      // this is the unmapped property
      if(filter.State.IsNotNullOrEmpty())
      {
          result = result.Where(g =&gt; g.State == filter.State);
      }
  
      // This will throw Class Member Unmapped exception
      return new List&lt;GreenGroup&gt;(result);
  }
  </code></pre>
  
  <p>However, since <code>State</code> is not a field in the database, does that mean I cannot include it in my linq query, but would have to further filter my list after the query returns?</p>
  
  <p>I've looked at a few sites including this <a href="http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/016ad28b-f813-4f26-9e70-2265a1943bad/" rel="nofollow">one</a> in which the user receives the same exception <code>Class Member unmapped</code> but the field is in their database so it doesn't look like an explicit cast will help me out.</p>
  
  <p>Is my only option to split up the filtering like so?</p>
  
  <pre><code>public List&lt;GreenGroup&gt; GetGreenGroups(GroupFilter filter)
  {
      IQueryable&lt;VirtualMachineInfo&gt; result = GetAllGroupsInternal(userContext);
  
      if(filter.OwnerId != Guid.Empty)
      {
          result = result.Where(g =&gt; g.OwnerID == filter.OwnerId);
      }
  
      var groups = new List&lt;GreenGroup&gt;(result);
  
      if(filter.State.IsNotNullOrEmpty())
      {
          groups = (from g in groups where g.State == filter.State select g).ToList();
      }
  
      return groups;
  }
  </code></pre>