lundi 29 juin 2015

Filter records within dbcontext object

I am using Entity Framework 6 database first approach.

I have three tables:

1.SystemRoles

2.MasterAppMenu

3.EmployeeRoleMenuMappings

A SystemRole can have multiple MasterAppMenu, so this is one to many relationship.

This i am trying to do.

private myEntities entities = new myEntities();
var roleMenuMappings = entities.SystemRoles.Where( x => x.EmployeeRoleMenuMappings.Select(  m => m.MasterAppMenu.ParentMenuId==null  )  );
var roleMenuList = await roleMenuMappings.ToListAsync();
return View(roleMenuList);

I want to filter the records of MasterAppMenu which has null value in field ParentMenuId.

Please tell me how to achieve this, i know it can be done on view side , but i want to do it on controller side only

Aucun commentaire:

Enregistrer un commentaire