DataServiceContext.TryGetEntity<TEntity> Method
Test retrieval of an entity being tracked by the DataServiceContext by reference to the URI of the entity.
Namespace: System.Data.Services.Client
Assembly: Microsoft.Data.Services.Client (in Microsoft.Data.Services.Client.dll)
Syntax
'Declaration
Public Function TryGetEntity(Of TEntity As Class) ( _
identity As Uri, _
<OutAttribute> ByRef entity As TEntity _
) As Boolean
'Usage
Dim instance As DataServiceContext
Dim identity As Uri
Dim entity As TEntity
Dim returnValue As Boolean
returnValue = instance.TryGetEntity(identity, _
entity)
public bool TryGetEntity<TEntity>(
Uri identity,
out TEntity entity
)
where TEntity : class
public:
generic<typename TEntity>
where TEntity : ref class
bool TryGetEntity(
Uri^ identity,
[OutAttribute] TEntity% entity
)
member TryGetEntity :
identity:Uri *
entity:'TEntity byref -> bool when 'TEntity : not struct
JScript does not support generic types and methods.
Type Parameters
- TEntity
The type of the entity.
Parameters
- identity
Type: System.Uri
The URI of the tracked entity to be retrieved.
- entity
Type: TEntity%
The entity to be retrieved.
Return Value
Type: System.Boolean
If an entity is found at resourceUri, the entity is returned in the out parameter entity and true is returned. If no entity is found, false is returned.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | When identity is nulla null reference (Nothing in Visual Basic). |
Remarks
If an entity is in the Detached or Added state, it does not have a URI and cannot be retrieved by using this method.