title: Entity Framework: selecting from multiple tables
body: <p>I have a statement:</p>
  
  <pre><code>var items = from e in db.Elements
      join a in db.LookUp
      on e.ID equals a.ElementID
      where e.Something == something
      select new Element
      {
          ID = e.ID,
          LookUpID = a.ID
          // some other data get populated here as well
      };
  </code></pre>
  
  <p>As you can see, all I need is a collection of Element objects with data from both tables - Elements and LookUp. This works fine. But then I need to know the number of elements selected:</p>
  
  <pre><code>int count = items.Count();
  </code></pre>
  
  <p>... this call throws System.NotSupportedException:</p>
  
  <p>"The entity or complex type 'Database.Element' cannot be constructed in a LINQ to Entities query."</p>
  
  <p>How am I supposed to select values from multiple tables into one object in Entity Framework? Thanks for any help!</p>