+2  A: 

You should be able to do something like this:

Dim ParentId As Guid = DirectCast(TreeViewThings.SelectedItem, Thing).Id
NewThing.Parent = (From t In db.Thing _
                  Where t.Id = ParentId _
                  Select t).First

That will build the hierarchical model you are going for.

achinda99
That was the nudge in the right direction that I needed. Thanks. It generates an extra select query now, but only the one insert.
Zack Peterson
No problem. If ParentId is a field in your table, you should be able to do:Dim ParentId As Guid = DirectCast(TreeViewThings.SelectedItem, Thing).IdThing.ParentId = ParentIddb.SaveChanges()TreeViewThings.UpdateLayout()No? It would save you the select.
achinda99
Lost all the formatting I had, but I'm sure you can figure out what I was trying to say. I never understood why in VB, the syntax used a newline to determine end of statement and not another character (like ";" in C#)
achinda99
'ParentId' is not a member of 'Thing'. I can't just deal in GUIDs.
Zack Peterson
I was mistaken. This hasn't quite solved the problem.
Zack Peterson
What is the error? And how does "set" work for Parent?
achinda99
I've updated the question with additional information.
Zack Peterson