Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Public Class Company
- Public Property Name As String
- End Class
- Public Enum Format
- Style1
- Style2
- Style3
- End Enum
- Public Class Definition
- Public Property ID As Integer
- Public Property Company As Company
- Public Property Format As Format
- End Class
- Sub Main()
- Dim defs As New List(Of Definition)()
- defs.Add(New Definition() With {.ID = 1, .Company = Nothing, .Format = Format.Style1})
- defs.Add(New Definition() With {.ID = 2, .Company = Nothing, .Format = Format.Style2})
- defs.Add(New Definition() With {.ID = 3, .Company = Nothing, .Format = Format.Style3})
- defs.Add(New Definition() With {.ID = 4, .Company = Nothing, .Format = Format.Style1}) '-- <<< WILDCARD 1
- defs.Add(New Definition() With {.ID = 4, .Company = New Company() With {.Name = "Test"}, .Format = Format.Style1}) '-- <<< WILDCARD 2
- '-- Get groups
- Dim byFormat = From d In defs
- Group d By KeyedFormat = New With {Key .Format = d.Format, Key .Company = d.Company} Into Group
- Select New With
- {
- .Company = KeyedFormat.Company,
- .Format = KeyedFormat.Format,
- .Definitions = Group.OrderByDescending(Function(x) x.ID)
- }
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement