views:

112

answers:

2

i have function

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

now i need to add condition to child list ChildMenu something like fieldname=id. how can i do it?

A: 

I'm not certain what you are trying to do, I think that the example might be better if it were split into two or three statements to break down the problem (it can be refactored into a single line when it is fixed).

If you could extend the question I'll try and help when I'm less tired.

amelvin
None of these are going to compile since I'm sure you meant == instead of =, but the first one I don't even understand what the 2nd => is supposed to do.
Davy8
Sorry, blind coding when I should be in bed. Yes some == instead of = might help!
amelvin
+1  A: 
return _dataContext.Menu.Include("ChildMenu").Where(m => m.MenuId == id && m.ChildMenu.IsDeleted == false).FirstOrDefault();
Richard Hein