An anonymous type is returned containing the Id, Name and Pay : Anonymous Object « LINQ « VB.Net






An anonymous type is returned containing the Id, Name and Pay

  
Imports System
Imports System.Xml.Linq

    Public Class MainClass
        Public Shared Sub Main()
            Dim employees As XElement = XElement.Load("Employees.xml")


            Dim query = From ele In employees.<Employee> _
                        Where CDbl(ele.<HourlyRate>.Value) >= 100 _
                        Select ele.@id, ele.<Name>.Value, Pay = CDbl(ele.<HourlyRate>.Value) _
                        Order By Name
            For Each emp In query
                Console.WriteLine("[{0,-2}] {1,-25} ${2,-6}", emp.id, emp.Name, emp.Pay.ToString("##.00"))
            Next

        End Sub

    End Class

   
    
  








Related examples in the same category

1.Linq way of doing Object creation
2.Create anonymous type from query
3.Create anonymous type in query and convert to array
4.Calls ToString() on each anonymous object
5.Get structured data which only accounts for the Make and Color of each item