bring menus and active submenus C #

4

I have to make a query by the menu that I have to bring only the active submenus, see my code.

return context.Set<Menu>().Include("MenuGroups")
              .Where(x => x.Id == id && x.MenuGroups.Any(z => z.Active))
              .FirstOrDefault();

My feedback keeps bringing my submenus with status false

    
asked by anonymous 30.01.2017 / 16:02

1 answer

4

You need to install a package to add filtering functionality to include , install:

  

PM> Install-Package Z.EntityFramework.Plus.EF6

add the package reference:

using Z.EntityFramework.Plus;

then code:

return context.Set<Menu>()
              .IncludeFilter(x => x.MenuGroups.Where(z => z.Active == true))
              .Where(x => x.Id == id)
              .FirstOrDefault();

30.01.2017 / 16:50