title: Entity Framework - Database View or Joins in Linq to Entities
body: <p>I have a database table with many lookup tables:</p>
  
  <pre><code>OrderType  
  ShippingType  
  etc.
  </code></pre>
  
  <p>My Order table is referencing each one of these tables:</p>
  
  <pre><code>Order
    OrderID
    OrderTypeID
    ShippingTypeID
  </code></pre>
  
  <p>I am using the Entity Framework as my data access layer. I have a page that needs to display information for an Order. I am struggling to figure out the best/right way to use these entities.</p>
  
  <p>My page should be displaying the data like:</p>
  
  <p>Order #1000000<br>
  Shipping Type: UPS<br>
  Order Type: Online<br>
  Etc Type: Etc.</p>
  
  <p>Is it better to create a view in the database that brings back the data I need and then add it to my entity model, and just use that directly so I don't have to write joins in my queries? Or is it better to create an intermediate class like so:</p>
  
  <pre><code>class OrderView
  {
      public int OrderNumber { get; set; }
      public string OrderType { get; set; }
      public string ShippingType { get; set; }
  }
  
  var order = from o in db.Orders
              join ot in db.OrderTypes on o.OrderTypeID equals ot.OrderTypeID
              join st in db.ShippingTypes on o.ShippingTypeID equals st.ShippingTypeID
              select new OrderView 
              { 
                  OrderNumber = o.OrderNumber, 
                  ShippingType = st.Description, 
                  OrderType = ot.Description 
              };
  </code></pre>
  
  <p>What is the better way here?</p>