Am having issues loading navigation(child ) element from a controller to a view
I created this model
public class MultipleItems
{
public IEnumerable<Order> Orders { get; set; }
public IEnumerable<support> Supports { get; set; }
public IEnumerable<DbModel.Track> Tracks { get; set; }
public IEnumerable<Receipt> Receipts { get; set; }
public IEnumerable<Quota> Quotas { get; set; }
}
And the controller
public ActionResult Client()
{
string useremail = User.Identity.GetUserName();
var myModel = new MultipleItems();
myModel.Supports = new SupportW().GetSupports(useremail);
myModel.Orders = new Orders().GetOrders(useremail);
myModel.Receipts = new Receipts().GetReceipts(useremail);
myModel.Tracks = new Track().GetTracks(useremail);
myModel.Quotas = new Quotas().GetQuota(useremail);
return View(myModel);
}
Am interested in Tracks()
and this is the method
public IEnumerable<DbModel.Track> GetTracks(string email)
{
try
{
using (var da = new CourierEntities())
{
da.Tracks.Include(a => a.Order);
da.Tracks.Include(a => a.Order.User);
da.Tracks.Include(a => a.destination);
da.Tracks.Include(a => a.Source);
da.Tracks.Include(a => a.CurrentLocation);
var q = (from p in da.Tracks where p.Order.User.Email == email select p).ToList();
if (q != null)
{
return q;
}
}
return null;
}
catch (Exception ex)
{
returnMsg = ex.Message;
return null;
}
}
While the view is
<td>
@if (Model.Orders.Count() != 0)
{
foreach (var i in Model.Tracks)
{
<tr>
Order id @i.OrderID
<br />
Trackid @i.TrackID
<br />
@i.Order.Packagename
</tr>
}
}
</td>
am having issues with @i.Order.Packagename and i recieve this error
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
Source Error: Line 120: Line 121: <br /> Line 122: @i.Order.Packagename Line 123: </tr>