Hi,
I use EF 5 with the "Include" statement such as:
public ActionResult List([DataSourceRequest] DataSourceRequest request)
{
... initialize context...
context.Configuration.ProxyCreationEnabled = false;
IQueryable<User> set = context.Set<User>().Include(u => u.Country);
return Json(set.ToDataSourceResult(request));
}
(In order to avoid erros such as "circular reference", I had to disable EF proxy creation.)
The grid works fine until the user starts grouping the columns, at which point the included objects are null, causing the JS to fail and not display the expected data any more.
If I enumerate the source to memory prior to converting to DataSourceResult, it works, the includes are present:
public ActionResult List(DataSourceRequest request)
{
... initialize context...
context.Configuration.ProxyCreationEnabled = false;
IQueryable<User> set = context.Set<User>().Include(u => u.Country);
set.ToArray().AsQueryable(); // if I do this it works with Groups...
return Json(set.ToDataSourceResult(request));
}
How can I make it work without enumerating the data source in memory first? I do not want to use model projection if possible to avoid the 'Include".
Thank you,
Lusu
I use EF 5 with the "Include" statement such as:
public ActionResult List([DataSourceRequest] DataSourceRequest request)
{
... initialize context...
context.Configuration.ProxyCreationEnabled = false;
IQueryable<User> set = context.Set<User>().Include(u => u.Country);
return Json(set.ToDataSourceResult(request));
}
(In order to avoid erros such as "circular reference", I had to disable EF proxy creation.)
The grid works fine until the user starts grouping the columns, at which point the included objects are null, causing the JS to fail and not display the expected data any more.
If I enumerate the source to memory prior to converting to DataSourceResult, it works, the includes are present:
public ActionResult List(DataSourceRequest request)
{
... initialize context...
context.Configuration.ProxyCreationEnabled = false;
IQueryable<User> set = context.Set<User>().Include(u => u.Country);
set.ToArray().AsQueryable(); // if I do this it works with Groups...
return Json(set.ToDataSourceResult(request));
}
How can I make it work without enumerating the data source in memory first? I do not want to use model projection if possible to avoid the 'Include".
Thank you,
Lusu