How to use LINQ expression inline in VB.NET

Web developers can create and call a method inline based on LINQ expression. For example they can create a function named TestClient() that examines a client an return true or false based on whether they want to include it in the results:

 

Private Function TestClient(ByVal client As Client) As Boolean

Return client.LastName.StartsWith(“D”)

End Function

 

Web developers could use the TestClient method like this:

 

Dim clients As List(Of Client) = New List(Of Client)()

 

Dim matches = From client In clients

Where TestClient(client)

Select client