Multiple Where clauses in Lambda expressions
Can be
x => x.Lists.Include(l => l.Title)
.Where(l => l.Title != String.Empty && l.InternalName != String.Empty)
or
x => x.Lists.Include(l => l.Title)
.Where(l => l.Title != String.Empty)
.Where(l => l.InternalName != String.Empty)
When you are looking at Where
implementation, you can see it accepts a Func(T, bool)
; that means:
T
is your IEnumerable typebool
means it needs to return a boolean value
So, when you do
.Where(l => l.InternalName != String.Empty)
// ^ ^---------- boolean part
// |------------------------------ "T" part
The lambda you pass to Where
can include any normal C# code, for example the &&
operator:
.Where(l => l.Title != string.Empty && l.InternalName != string.Empty)