当另一个 EntityObject 中的一个特定(计算的)属性发生更改时,我需要向 Context 添加一个新的 EntityObject。似乎无法从任何 EntityObject 本身访问 Context。
例如,我的“Employee”部分类有一个自定义属性:
Public Property Age As Integer
Get
Return _Age
End If
End Get
Set(value As Integer)
'Here based on some conditions, I sometimes need to add a new
'EntityObject to (or modify an existing EntityObject) in an EntitySet "Assumptions"
'HOW TO DO THAT ?
_Age=value
End Set
End Property
Private _Age as Integer
...并且当设置了上述“年龄”时,我有时需要创建一个新的实体对象“假设”并将其添加到同一上下文下的“假设”实体集。
我知道这样从另一个 EntityObjects 访问 EntityObjects 并不是一个好的设计,但是我怎样才能以其他方式解决这个需求呢?