DataServiceContext.AttachTo 方法 (String, Object)
通知 DataServiceContext 开始跟踪指定资源,并在指定资源集中提供该资源的位置。
命名空间: System.Data.Services.Client
程序集: Microsoft.Data.Services.Client(在 Microsoft.Data.Services.Client.dll 中)
语法
声明
Public Sub AttachTo ( _
entitySetName As String, _
entity As Object _
)
用法
Dim instance As DataServiceContext
Dim entitySetName As String
Dim entity As Object
instance.AttachTo(entitySetName, entity)
public void AttachTo(
string entitySetName,
Object entity
)
public:
void AttachTo(
String^ entitySetName,
Object^ entity
)
member AttachTo :
entitySetName:string *
entity:Object -> unit
public function AttachTo(
entitySetName : String,
entity : Object
)
参数
- entitySetName
类型:System.String
包含该资源的集的名称。
- entity
类型:System.Object
将由 DataServiceContext 跟踪的资源。在“未更改”状态下附加资源。
异常
异常 | 条件 |
---|---|
ArgumentNullException | 当 entity 或 entitySetName 为 nullnull 引用(在 Visual Basic 中为 Nothing) 时。 |
ArgumentException | 当 entitySetName 为空字符串时。 - 或 - 当 entity 未定义键属性时。 |
InvalidOperationException | 当 entity 已由上下文跟踪时。 |
注释
如果实体为对象图的一部分,则此操作不会遍历该图来添加相关对象。 此操作为浅表操作。
该方法不会验证指定的实体集是否出现在与 DataServiceContext 关联的数据服务中。