linq包含条件

时间:2010-03-01 23:57:16

标签: linq include entity

我有功能

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

现在我需要为子列表添加条件ChildMenu类似于fieldname = id。我怎么能这样做?

1 个答案:

答案 0 :(得分:2)

return _dataContext.Menu.Include("ChildMenu")
     .Where(m => m.MenuId == id && m.ChildMenu.IsDeleted == false).FirstOrDefault();