DataServiceContext.Detach 方法
從 DataServiceContext 正在追蹤的實體清單中移除實體。
命名空間: System.Data.Services.Client
組件: Microsoft.Data.Services.Client (在 Microsoft.Data.Services.Client.dll 中)
語法
'宣告
Public Function Detach ( _
entity As Object _
) As Boolean
'用途
Dim instance As DataServiceContext
Dim entity As Object
Dim returnValue As Boolean
returnValue = instance.Detach(entity)
public bool Detach(
Object entity
)
public:
bool Detach(
Object^ entity
)
member Detach :
entity:Object -> bool
public function Detach(
entity : Object
) : boolean
參數
- entity
型別:System.Object
要從 DataServiceContext 中斷連結的追蹤實體。
傳回值
型別:System.Boolean
如果指定的實體已卸離則傳回 true,否則為 false。
例外狀況
例外狀況 | 條件 |
---|---|
ArgumentNullException | 當 entity 為 nullnull 參考 (在 Visual Basic 中為 Nothing) 時。 |
備註
物件卸離後就不再受到 DataServiceContext 追蹤。
可以呼叫 Detach 方法卸離任何物件,而不管其 EntityStates。
在中斷連結指定的實體之後,這個方法也會一併中斷連結與實體相關的任何連結。