How to use LINQ expression to get a subset of data in VB.NET

In the article How LINQ expression is composed LINQ select clause was described. Web developer can change it to get a subset of data. For example, he/she could pull out a list of first name strings like this:

 

Dim matches = From client In clients _

select client.FirstName

 

or a list of strings with both first, middle and last names:

Dim matches = From client In clients _

select client.FirstName + “  “ + client.MiddleName + “  “ + client.LastName

 

Web developer can use standard VB.NET operators on numeric data or strings to modify the information as he/she’s selecting it. This changes the type of collection that’s returned—it’s now an IEnumerable<string> collection of strings, rather than a collection of Client objects.