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)
using (MobookaEntities entities = new MobookaEntities(false))
IQueryable<Campaign> campaigns = entities.Campaigns.Include("Offer")
dataSourceResult = campaigns.ToDataSourceResult(request);
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!