DataServiceContext.TryGetEntity<TEntity> 方法
通过引用实体的 URI,测试由 DataServiceContext 跟踪的实体的检索。
命名空间: System.Data.Services.Client
程序集: Microsoft.Data.Services.Client(在 Microsoft.Data.Services.Client.dll 中)
语法
声明
Public Function TryGetEntity(Of TEntity As Class) ( _
identity As Uri, _
<OutAttribute> ByRef entity As TEntity _
) As Boolean
用法
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 不支持一般类型和方法。
类型参数
- TEntity
实体的类型。
参数
- identity
类型:System.Uri
要检索的被跟踪实体的 URI。
- entity
类型:TEntity%
要检索的实体。
返回值
类型:System.Boolean
如果在 resourceUri 中发现实体,则在输出参数 entity 中返回该实体并返回 true。如果未发现实体,则返回 false。
异常
异常 | 条件 |
---|---|
ArgumentNullException | 当 identity 为 nullnull 引用(在 Visual Basic 中为 Nothing) 时。 |
注释
如果实体处于 Detached 或 Added 状态,则该实体不含 URI,因此无法使用此方法进行检索。