我在两个表上有一对一的关系,在我的EDM中由2个类表示。
我正在尝试保存新记录,并且很困惑如何保存到第二个实体。我尝试了以下内容。
Dim myObject as new MyObject
myObject.prop1 = 5
myObject.prop2 = "Test"
myObject.myOtherObject.prop1 = 3
myObject.myOtherObject.prop2 = "Hello"
但是当我点击myObject.myOtherObject.prop1 = 3
时收到错误,因为myOtherObject
尚未初始化。
如何在myObject
下初始化子对象?
答案 0 :(得分:1)
尝试:
Dim myObject as new MyObject
myObject.prop1 = 5
myObject.prop2 = "Test"
myObject.myOtherObject = new MyOtherObject
myObject.myOtherObject.prop1 = 3
myObject.myOtherObject.prop2 = "Hello"