I’m looking exactly the same
How to efficiently query with filter on children at different levels?
but “in lambdas” syntax.
I am really need this, can anybody help? Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is the code snippet from the post you referenced in both the query syntax and the lambda syntax: https://stackoverflow.com/a/12324116/670028:
LINQ query syntax:
LINQ lambda syntax:
As you can see, it’s not as “clean” as the LINQ query syntax because you have to continue to project into a new anonymous type each time you use the .SelectMany() method. It can also get a little confusing with the all of those variable names which is why I tend to use the LINQ query syntax instead of lambdas when I need to perform queries like this.
And just for fun, here is an example of using .SelectMany() that looks a little better and more realistic by giving the anonymous types more meaningful names: