views:

45

answers:

1

I have a one-to-one relationship on two tables with are represented by 2 classes in my EDM.

I am trying to save a new record and am confused how to save to the second entity. I have tried the following.

Dim myObject as new MyObject

myObject.prop1 = 5
myObject.prop2 = "Test"

myObject.myOtherObject.prop1 = 3
myObject.myOtherObject.prop2 = "Hello"

But I get an error when I hit myObject.myOtherObject.prop1 = 3 because myOtherObject hasn't been initialized.

How do I initialize an child object under myObject?

+1  A: 

Try:

Dim myObject as new MyObject

myObject.prop1 = 5
myObject.prop2 = "Test"

myObject.myOtherObject = new MyOtherObject
myObject.myOtherObject.prop1 = 3
myObject.myOtherObject.prop2 = "Hello"
Craig Stuntz