vb.net

How to use LINQ group clause to group results in VB.NET

Web developer can use LINQ group clause to group his/her results based on a key that he/she specifies. For example Web developer could specify that the results should be grouped by the City so that all clients from New York or San Francisco are in individual groups. In this case client.City is the key.

 

Dim qryClientsByCity = From client …

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 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 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 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 LINQ expression is composed in VB.NET

LINQ expressions have a superficial similarity to SQL queries, but the order of the clauses is rearranged.

All LINQ expressions must have a from clause that indicates the data source and a select clause that

indicates the data Web developer wants to retrieve (or a group clause that defines a series of groups into which the data should be placed). …

Learn more

How LINQ works with in memory collections in VB.NET

Web developer uses in this case the simplest form of LINQ – LINQ to Objects.  Let for example Web developer has some sort of data class, like the Clients class shown next:

 

Public Class Client

Private _ClientID As Integer

Private _FirstName As String

Private _LastName As String

Private _TitleOfCourtesy As String

 

Public Sub Client(ByVal CliID As Integer, ByVal FName As String, _

Learn more

How to restrict access to all application pages in VB.NET

Web developer follows the approach described in the article, when he/she has to restrict access to the pages of his/her application to authorized users only. In this case Web developer should change the web.config settings of his/her application to specify Forms authentication, and then create an .aspx login page to collect user credentials and complete the authentication check.

Web …

Learn more

How to use Ajax partial rendering in VB.NET

Let start with a classical example – Web developer works under application which has a Web page with two drop-down lists. The first one contains all the cities in the country, and the second one contains the bank branches locations in the selected city. Web developer needs to populate the second drop-down list with the correct locations each …

Learn more

How to read XML file in VB.NET

Suppose that the user has to read the XML file he/she already generated. The application should provide functionality to extract all vendors from Canada, and after that the user has to process them in alphabetic order.

 

Web developer has to follow these steps:

   1.Create the XDocument using the XML.
   2.Navigate the XElement elements to reach the Vendor ones.
   3.Take the XElement instances …

Learn more