Hi,
I'm trying to use the ToDataSourceResult inside an MVC 4 Web API controller like so (wrong, I know, please help)
But I'm getting the following error:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
I kind of understand why I'm getting this and if I copied the DataSourceResult object into a different object and returned that then it would work, however, I would like to know what do I need to do to have the LINQ executed and returned in my controller. Thank you!
I'm trying to use the ToDataSourceResult inside an MVC 4 Web API controller like so (wrong, I know, please help)
public DataSourceResult Get([DataSourceRequest] DataSourceRequest request) { DataSourceResult dataSourceResult; using (MobookaEntities entities = new MobookaEntities(false)) { IQueryable<Campaign> campaigns = entities.Campaigns.Include("Offer") .Include("Offer.Advertiser") .Include("Offer.Advertiser.Company") .Include("Publisher") .Include("Publisher.Company") .Include("Publisher.Employee") .Include("Publisher.Employee.Profile") .Include("Publisher.Profile") .Include("Status");dataSourceResult = campaigns.ToDataSourceResult(request);}
return dataSourceResult; }
But I'm getting the following error:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
I kind of understand why I'm getting this and if I copied the DataSourceResult object into a different object and returned that then it would work, however, I would like to know what do I need to do to have the LINQ executed and returned in my controller. Thank you!