Hi,
I have the following code in my controller and in the mapping of my entity I navigate a foreign key. (Plate = anomalie.voiture.plaque)
That gives me the following exception:
An exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.dll but was not handled in user code
There is already an open DataReader associated with this Connection which must be closed first.
I tried to add an include() but doesn't solve the problem. Any ideas ?
public
ActionResult Read([DataSourceRequest]DataSourceRequest request)
{
using
(var context =
new
carpackEntities())
{
IQueryable<anomalie> damages = context.anomalie;
damages.Include(d => d.voiture);
var result = Json(damages.ToDataSourceResult(request, damage =>
new
DamageViewModel()
{
Date = damage.dtajout,
Description = damage.avarie,
Driver = damage.chauffeur,
Plate = damage.voiture.plaque,
Service = damage.service,
State = damage.etat.ToString()
}));
return
result;
}
}