I'm trying to figure out how to add an enumeration to an object with Linq. For example:
Dim thingBlock = <Things>
<Thing Name="Ish">
<SmallThing>Jibber</SmallThing>
<SmallThing>Jabber</SmallThing>
</Thing>
<Thing Name="Ugly Guy">
<SmallThing Name="Carl"></SmallThing>
<SmallThing Marks="Marks"></SmallThing>
</Thing>
</Things>
Dim myList As New List(Of Thing)
myList.AddRange(thingBlock.<Thing>.Select(Function(th) New Thing With {.Name = th.@Name}))
Public Class Thing
Public Property Name As String
Public Property SmallThings As New List(Of String)
End Class
This works well to create new Thing
and add them to myList
, but I can't figure out how to add the IEnumerable of String to my SmallThings
list. For example, this doesn't work:
myList.AddRange(thingBlock.<Thing>.Select(Function(th) New Thing With {.Name = th.@Name, th.Select(Function(st) .SmallThings.Add([email protected])}))
I just want to add all the <SmallThing>.@Name
to SmallThings
property of the Thing
class.