Lambda expression returning error
c#, lambda
Solution
Assuming you're trying to return the result of that `.Where()` query, you need to drop those braces and that semicolon:
SomeFunction(m => ViewData["AllEmployees"].Where(c => c.LeaderID == m.UserID))
If you put them there, `ViewData[...].Where()` will be treated as a statement and not an expression, so you end up with a lambda that doesn't return when it's supposed to, causing the error.
Or if you insist on putting them there, you need a `return` keyword so the statement actually returns:
SomeFunction(m =>
{
return ViewData["AllEmployees"].Where(c => c.LeaderID == m.UserID);
})
Problem
This is my code: ``` SomeFunction(m => { ViewData["AllEmployees"].Where(c => c.LeaderID == m.UserID); }) ``` and it returns this error: Not all code paths return a value in lambda expression of type `System.Func<IEnumerable>`