Is it possible to have something similar to an SQL 'WHERE' clause in a For Each
loop in VB.NET?
I.E.
FOR EACH event IN events
'WHERE eventdate=getdate
NEXT
in LINQ it would be (.NET 3.5 or higher)
For Each event in events.Where(Function(x) x.eventdate = getdate)
'Process event
Next
And Non-Linq (.Net 2.0 or lower)
For Each event in events
If event.eventdate = getdate Then
'Process event
End If
Next
With LINQ:
For Each p As Person In (From pers In Persons Where pers.Firstname = "Stefan")
'Only handle persons with first name "Stefan"
MsgBox(p.LastName)
Next
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With