Domanda

Why when my entities contain non-empty ICollection properties kendo grid not displays data? This occurs when I using code-first models with foreign key relations - parent entities that have childs made grid not display data and viсe versa: childs that have non-empty parents mades grid not work properly.Here is line of code that returns data from controller:

 return Json(context.SomeDBSet.ToDataSourceResult(request));

here are entities:

public class ParentModel
{
    .....
    public virtual ICollection<ChildModel> ArticleContent { get; set; }

}

public class ChildModel
{
    ....
    public int? ParentModelId { get; set; }
    public virtual ParentModel ParentModel { get; set; }
}
È stato utile?

Soluzione

Here is solution:

 return Json(context.SomeDBSet.Select( e => new { e.X, ....  e.Id}).ToDataSourceResult(request));

Dont include your 'ICollection' properties here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top