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
{
ViewBag.Title = "GroupBy";
}
GroupBy
@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
Shuvojit HalderPosted Jul 9, 2015, 6:11 AM
Shuvojit HalderPosted Jul 9, 2015, 6:46 AM
nisha ashaPosted Jul 9, 2015, 6:34 AM