Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Linq vb.net mulitple columns grouping blues
Message
 
To
All
General information
Forum:
ASP.NET
Category:
LINQ
Title:
Linq vb.net mulitple columns grouping blues
Miscellaneous
Thread ID:
01559563
Message ID:
01559563
Views:
65
Update So sorry. There's nothing wrong with my code. Tweaked the ide and must have gotten rid of the debug.output.

I wonder why this does not work. I'm not getting any output. The code was copied from http://stackoverflow.com/questions/10801859/linq-group-by-multiple-values-does-not-work-well-in-vb-net-but-work-well-in-c-sh
The poster seemed to say that it works, but it does not for me.
    Sub TestMain()
        Dim empList As New List(Of Employee)()
        empList.Add(New Employee() With {.ID = 1, .FName = "John", .Age = 23, .Sex = "M"c})
        empList.Add(New Employee() With {.ID = 2, .FName = "Mary", .Age = 25, .Sex = "F"c})
        empList.Add(New Employee() With {.ID = 3, .FName = "Amber", .Age = 23, .Sex = "M"c})
        empList.Add(New Employee() With {.ID = 4, .FName = "Kathy", .Age = 25, .Sex = "F"c})
        empList.Add(New Employee() With {.ID = 5, .FName = "Lena", .Age = 27, .Sex = "F"c})
        empList.Add(New Employee() With {.ID = 6, .FName = "Bill", .Age = 28, .Sex = "M"c})
        empList.Add(New Employee() With {.ID = 7, .FName = "Celina", .Age = 27, .Sex = "F"c})
        empList.Add(New Employee() With {.ID = 8, .FName = "John", .Age = 28, .Sex = "M"c})

        Dim query = From el In empList Group el By Key = New With {Key el.Age, Key el.Sex} Into Group Select New With {.key = Key, .count = Group.Count()}

        For Each Cat In query
            Debug.Print(Cat.ToString)
        Next
        MsgBox("coucou")
    End Sub


    Public Class Employee
        Private privateID As Integer
        Public Property ID() As Integer

            Get
                Return privateID
            End Get

            Set(ByVal value As Integer)
                privateID = value
            End Set

        End Property

        Private privateFName As String
        Public Property FName() As String
            Get
                Return privateFName
            End Get

            Set(ByVal value As String)
                privateFName = value
            End Set
        End Property

        Private privateAge As Integer
        Public Property Age() As Integer
            Get
                Return privateAge
            End Get

            Set(ByVal value As Integer)
                privateAge = value
            End Set
        End Property

        Private privateSex As Char
        Public Property Sex() As Char
            Get
                Return privateSex
            End Get

            Set(ByVal value As Char)
                privateSex = value
            End Set
        End Property
    End Class

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Reply
Map
View

Click here to load this message in the networking platform