I have a Blogs table related to BlogComments table with a FK.
I need to get, through Linq, all the BlogComments items that match a certain flag
If i do:
db.Blogs.Where(b => b.BlogComments.Where(bc=>bc.Where(bc.Flag1==true));
I get “Cannot implicity convert type IEnumerable to bool”
Which is the best way to solve this problem?
Because this expression:
returns an IEnumerable (of BlogComments), but you are then passing it into this method:
which expects a function that returns a bool, not an IEnumerable.
You probably need something like this:
If you need to select comments from multiple blogs, then you could try using Contains:
If you want to place criteria on the set of blogs, as well as the comments, then you could do this in one query using a join: