In my MVC5 application I have table lets's say it's name is Student and every student belonging to a Team. I want to show students according to their teams by percentage. For this reason I also created a ViewModel in order to join Student entity with Team entity. So, how can I show the data I want on Kendo UI pie chart? Could you have a look at the code and correct the mistakes below? And could you give a View samples suitable to this approach? Thanks in advance.
ViewModel:
public class StudentViewModel
{
public int StudentId { get; set; }
public int TeamId { get; set; }
public string TeamName { get; set; }
public int TeamPercentage { get; set; }
}
Controller:
public ActionResult Index_Read([DataSourceRequest] DataSourceRequest request)
{
var dataContext = repository.Student;
var result = dataContext.ToDataSourceResult(request, m => new StudentViewModel
{
StudentId = m.StudentId,
TeamId = m.TeamId,
TeamName = m.TeamName,
TeamPercentage = //??? How can I obtain percentage by Lambda Expression ???
}
);
return Json(result, JsonRequestBehavior.AllowGet);
}