LINQ TO OBJECTS

LINQ to Objects refers to methods that let a program extract data from objects that are extended by LINQ extension methods. These methods extend IEnumerable(Of T) so that they apply to any class that implements IEnumerable(Of T) including Dictionary(Of T), HashSet(Of T), LinkedList (Of T), Queue(Of T), SortedDictionary(Of T), SortedList(Of T), Stack(Of T), and others.

For example, the following code searches the all_customers list for customers with negative account balances. It orders them by account balance and returns their names and balances.

Dim overdue_custs =
    From cust In all_customers
    Where cust.AccountBalance < 0
    Order By cust.AccountBalance Ascending
    Select cust.Name, cust.AccountBalance

The result of this query is an IEnumerable object that the program can iterate through to take action for the selected customers.

All of the examples shown previously in this chapter use LINQ to Objects, so this section says no more about them. See the previous sections for more information and examples.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.124.24