title: Combining Tables With Different Data Using Linq in MVC?
body: <p>I have Two classes Named OfflineOrderLineItem.cs and OnlineOrderLineItem.cs  both have diff Order table named offline and Online</p>
  
  <p>In that i want to Combine the two tables data to search and Display the Fields from both tables</p>
  
  <p>How to do that using linq in mvc4 ??? any idea..... </p>
  
  <pre><code>public virtual IPagedList&lt;OnlineOrderLineItem&gt; SearchOrderLineItems(string PoNumber)
  {
       var query1 = (from ol in _offlineOrderLineItemRepository.Table
                     select new
                    {                            
                     ol.Name
  
                    }).ToList();
  
       var query2 = (from opv in _onlineOrderLineItemRepository.Table
                     select new
                     {
                      opv.Name
  
                     }).ToList();
  
       var finalquery = query1.Union(query2);
  
       if (!String.IsNullOrWhiteSpace(Name))
       finalquery = finalquery.Where(c =&gt; c.Name == Name);
       var orderlineitems = finalquery.ToList(); //its not working  it throw a error
       return new PagedList&lt;OnlineOrderLineItem&gt;(orderlineitems);//error 
      }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>cannot convert from 'System.Collections.Generic.List&lt;AnonymousType#1&gt;'
  to 'System.Linq.IQueryable&lt;Nop.Core.Domain.Management.OnlineOrderLineItem&gt;'
  to 'System.Linq.IQueryable&lt;Nop.Core.Domain.Management.OnlineOrderLineItem&gt;'
  </code></pre>