Share via


DataServiceContext.TryGetEntity<TEntity>(Uri, TEntity) 方法

定義

透過實體 URI 的參考進行測試擷取 DataServiceContext 正在追蹤的實體。

public:
generic <typename TEntity>
 where TEntity : class bool TryGetEntity(Uri ^ identity, [Runtime::InteropServices::Out] TEntity % entity);
public bool TryGetEntity<TEntity> (Uri identity, out TEntity entity) where TEntity : class;
member this.TryGetEntity : Uri * 'Entity -> bool (requires 'Entity : null)
Public Function TryGetEntity(Of TEntity As Class) (identity As Uri, ByRef entity As TEntity) As Boolean

類型參數

TEntity

實體的型別。

參數

identity
Uri

要擷取之追蹤實體的 URI。

entity
TEntity

要擷取的實體。

傳回

如果在 resourceUri 找到實體,則會以 out 參數 entity 傳回實體,並且傳回 true。 如果找不到實體,則會傳回 false。

例外狀況

identitynull 時。

備註

如果實體處於 DetachedAdded 狀態,它並沒有 URI,也不能使用此方法擷取。

適用於