title: Union in entity framework
body: <p>I have two tables: Vehicles and Workers.   </p>
  
  <pre><code>Vehicle(Id, Number)
  Workers(Id, Name, ContractorVehicleNumber)
  </code></pre>
  
  <p>I would like to write lambda query to return all the vehicles and the contractor vehicles. Something like in sql:</p>
  
  <pre><code>SELECT Id, Number
  FROM Vehicle
  UNION
  SELECT NULL, ContractorVehicleNumber
  FROM Workers
  </code></pre>
  
  <p>This is what I made:</p>
  
  <pre><code>public IQueryable&lt;Vehicle&gt; Get(bool includeContractorVehicles)
  {
      IQueryable&lt;Vehicle&gt; query = GetQuery();
  
      if (includeContractorVehicles == true)
      {
          WorkerRepository rep = new WorkerRepository();
          IQueryable&lt;Vehicle&gt; contractorsVehicles = rep.GetWirkers().
              Select(x =&gt; new Vehicle()
              {
                  VehicleNumber = x.ContractorVehicleNumber
              });
          query = query.Union(contractorsVehicles);
      }
  
      return query;
  }  
  </code></pre>
  
  <p>But I get an exception:</p>
  
  <blockquote>
    <p>The entity or complex type 'XXXXXXXX' cannot be constructed in a LINQ to Entities query.</p>
  </blockquote>