I have Grouped Via Linq in Mvc , Grouped and stored in var ,When i pass to view i have got error?
Error is : Its in generic list, Requires Igrouping dictionary type?
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[System.Linq.IGrouping`2[System.String,AngularCrudS.Empinfo]]', but this dictionary requires a model item of type 'System.Linq.IGrouping`2[System.String,AngularCrudS.Empinfo]'.
Anyone help pls
controller:
public class HomeController : Controller
{
public SQLChallengeEntities Sqlcontext = new SQLChallengeEntities();
public ActionResult GroupBy()
{
var EmpDesignationGrouped = Sqlcontext.Empinfoes.ToList().GroupBy(x => x.EmpDesignation).ToList();
return View(EmpDesignationGrouped);
}
View:
@model IGrouping<string,AngularCrudS.Empinfo>
{
ViewBag.Title = "GroupBy";
}
<h2>GroupBy</h2>
@foreach (var s in Model)
{
@s.EmpDesignation
foreach (var e in s.)
{
}
}
}
i am not able to put second foreach where i make the mistake