LINQ Tutorials

How to use LINQ orderby clause to sort results in VB.NET

Sometimes Web developers have to sort the returned data. The LINQ orderby clause sorts the elements in the returned sequence according to the default comparer for the type being sorted. For example, the following query can be extended to sort the results based on the FirstName property. Because FirstName is a string, the default comparer performs an alphabetical …

Learn more

How to use LINQ orderby clause to sort results in C#

Sometimes Web developers have to sort the returned data. The LINQ orderby clause sorts the elements in the returned sequence according to the default comparer for the type being sorted. For example, the following query can be extended to sort the results based on the FirstName property. Because FirstName is a string, the default comparer performs an alphabetical …

Learn more

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 …

Learn more

How to use LINQ expression inline in C#

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 bool TestClient(Client client)

{

return client.LastName.StartsWith(“T”);

}

 

Web developers could use the TestClient method like this:

 

var matches = …

Learn more

How to use LINQ where clause to filter results in VB.NET

Web developer can modify the where clause in LINQ statement to filter the results and to include only those that match a specific condition. The next code shows how to find clients who have a last name that starts with a specific letter:

Dim matches = From client In clients _

Where client.LastName.StartsWith(“D”) _

Select client

 

Web developer …

Learn more

How to use LINQ where clause to filter results in C#

Web developer can modify the where clause in LINQ statement to filter the results and to include only those that match a specific condition. The next code shows how to find clients who have a last name that starts with a specific letter:

 

var matches = from client in clients

where client.LastName.StartsWith(“P“)

select client;

 

Web developer can combine …

Learn more

How to use LINQ expression to do projection in VB.NET

Web developer can use approach described in the article How to use LINQ expression to get a subset of data in VB.NET to define a new class that wraps just the information he/she wants to return. For example, if he/she wants to get both the first and last names but he/she wants to store them in separate strings, …

Learn more

How to use LINQ expression to do projection in C#

Web developer can use approach described in the article How to use LINQ expression to get a subset of data in C# to define a new class that wraps just the information he/she wants to return. For example, if he/she wants to get both the first and last names but he/she wants to store them in separate strings, …

Learn more

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 …

Learn more

How to use LINQ expression to get a subset of data in C#

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:

var matches = from client in clients

select client.FirstName;

 

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

Learn more