Linq Groupby

Last post 07-09-2009 4:22 AM by anup1252000. 1 replies.

Sort Posts:

  • Linq Groupby

    07-09-2009, 1:55 AM

    i want result groupby roleoperation.menuid
    my linq code i wirte below code

     from roleoperation in db.RoleOperations
                                 join menu in db.Menus
                                        on roleoperation.MenuId equals menu.Id
                                join asprols in db.aspnet_Roles
                                        on roleoperation.RoleId equals asprols.RoleId
                                join aspusers in db.aspnet_UsersInRoles
                                        on asprols.RoleId equals aspusers.RoleId
                                //where aspusers.UserId.Equals(userId) && roleoperation.IsVisible.Equals(true) && roleIds.Contains(roleoperation.RoleId)
                                where aspusers.UserId.Equals(userId) && roleIds.Contains(roleoperation.RoleId)
                                orderby menu.Sequence
                                group roleoperation by roleoperation.MenuId


                                select new ePP2PL.MenusProperties()
                            {
                                Id = menu.Id,
                                Pagename = menu.PageName,
                                Tooltip = menu.ToolTip,
                                Parentid = menu.ParentId,
                                Sequence = menu.Sequence,
                                Name = menu.Name,
                                ParentidName = menu.ParentId,
                                CRUDAllowed = menu.CRUDAllowed,
                                IsMandatory = menu.IsMandatory

                                //prementname = abc.Parentname

                            };

                       




                return menuData;

    how can get result group by roleoperation menu id

    Nothing is really over,untill the moment stop trying for it...
    Amitsp(MCTS,MCP)
    sqlreporting.blogspot.com
  • Re: Linq Groupby

    07-09-2009, 4:22 AM
    Answer
    • Contributor
      2,470 point Contributor
    • anup1252000
    • Member since 11-12-2008, 3:26 AM
    • india
    • Posts 494

    write like this in ur application

    public partial class employee
    {
        public IEnumerable<employee> getemployee()
        {
            NorthwindDataContext db = new NorthwindDataContext();
            return db.employees.GroupBy(e => e.empname);
        }
    }

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution.

    Anup Hosur
    HP
    http://anup-anuphosur.blogspot.com/


Page 1 of 1 (2 items)