m.MenuId...">

Linq include condition

i has a function

public Menu Details(int? id) { return _dataContext.Menu.Include("ChildMenu").FirstOrDefault(m => m.MenuId == id); } 

Now I need to add a condition to the ChildMenu child list, for example fieldname = id. How can i do this?

+4
source share
1 answer
 return _dataContext.Menu.Include("ChildMenu") .Where(m => m.MenuId == id && m.ChildMenu.IsDeleted == false).FirstOrDefault(); 
+2
source

Source: https://habr.com/ru/post/1302816/


All Articles