mercredi 8 juillet 2015

How to Bind a group by data in view in mvc5? what are the best ways to do

  • Hi , I am using Entityframework context,i dont know how to bind to view.

    i am group via sex

    public SQLChallengeEntities Sqlcontext = new SQLChallengeEntities();

    var bookGrouped = Sqlcontext.Empinfoes.ToList().GroupBy(x => x.EmpSex).ToList();

    return View(bookGrouped.ToList());

    In View

    How to get the data

    @foreach (var s in Model)

    { @group.Sex foreach (var book in s.Values) { @s.Empname @s.EmpDesignation @s.EmpAge }


    I am getting this error

    The model item passed into the dictionary is of type 'System.Collections.Generic.List1[System.Linq.IGrouping2[System.String,AngularCrudS.Empinfo]]', but this dictionary requires a model iteenter code herem of type 'System.Collections.Generic.IEnumerable`1[AngularCrudS.Empinfo]

Aucun commentaire:

Enregistrer un commentaire