DataServiceContext.TryGetEntity<TEntity>(Uri, TEntity) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
测试通过 DataServiceContext 对实体 URI 的引用跟踪的实体的检索。
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。
例外
何时 identity 为 null。
注解
如果实体处于 Detached 或 Added 状态,则它没有 URI,并且无法使用此方法进行检索。