Sunday, 2 July 2017

Using more than one condition in linq's where method


You can roll your separate conditions into a single predicate if you like:
codebase.Methods.Where(x => (x.Body.Scopes.Count > 5) && (x.Foo == "test"));
Or you can use a separate Where call for each condition:
codebase.Methods.Where(x => x.Body.Scopes.Count > 5)
                .Where(x => x.Foo == "test");

No comments:

Post a Comment

Note: only a member of this blog may post a comment.