title: Linq: Inner join two tables and return as json for jquery datatable
body: <p>Im new here in using datatables and ajax in MVC ASP.net. Im having problem and its to difficult for me to solve this. I trying to join two tables as like the title says and return the result to json and display to datatable. but im getting an error of "The operation cannot be completed because the DbContext has been disposed.". Any help would be great for me to learn this language. thank you</p>
  
  <p>Here is my code</p>
  
  <pre><code>public ActionResult Rooms()
          {
              using (RoomReservationEntities db = new RoomReservationEntities())
              {
                  var room_query = from room in db.Rooms
                          join roomType in db.Room_Type
                          on room.RoomType_id equals roomType.RoomType_id
                          select new { room.Room_id, room.Room_name, roomType.RoomType, roomType.Room_rate };
  
                  return Json(new { data = room_query }, JsonRequestBehavior.AllowGet);
              }
          }
  </code></pre>
  
  <p>my cshtml</p>
  
  <pre><code>@{
      ViewBag.Title = "Rooms";
      Layout = "~/Views/Shared/_AdminMasterPage.cshtml";
  }
  
  &lt;h2&gt;Rooms&lt;/h2&gt;
  
  &lt;link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" /&gt;
  
  &lt;h2&gt;AdminRooms&lt;/h2&gt;
  
  &lt;div style="width:90%; margin:0 auto"&gt;
      &lt;table id="myDatatable"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Room Name&lt;/th&gt;
                  &lt;th&gt;Room Type&lt;/th&gt;
                  &lt;th&gt;Room Rate&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
  
      &lt;/table&gt;
  &lt;/div&gt;
  
  
  @section scritps{
      &lt;script src="~/Scripts/jquery.validate.min.js"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/jquery.validate.unobtrusive.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/jquery-ui-1.12.1.min.js"&gt;&lt;/script&gt;
  }
  
  &lt;script&gt;
      $(document).ready(function () {
          var oTable = $('#myDatatable').DataTable({
              "ajax": {
                  "url": '/Admin/Rooms',
                  "type": "get",
                  "datatype":"json"
              },
              "columns": [
                  { "data": "Room_name", "autoWidth": true },
                  { "data": "RoomType", "autoWidth": true },
                  { "data": "Room_rate", "autoWidth": true }
              ]
  
          })
      })
  &lt;/script&gt;
  </code></pre>