我有功能
public Menu Details(int? id)
{
return _dataContext.Menu.Include("ChildMenu").FirstOrDefault(m => m.MenuId == id);
}
现在我需要为子列表添加条件ChildMenu类似于fieldname = id。我怎么能这样做?
答案 0 :(得分:2)
return _dataContext.Menu.Include("ChildMenu")
.Where(m => m.MenuId == id && m.ChildMenu.IsDeleted == false).FirstOrDefault();