检索、更新和删除实体
发布日期: 2017年1月
适用于: Dynamics 365 (online),Dynamics 365 (on-premises),Dynamics CRM 2016,Dynamics CRM Online
本主题演示如何使用在创建自定义实体。中创建的自定义 Bank Account 实体检索、更新和删除实体。
本主题内容
检索和更新实体
删除自定义实体
检索和更新实体
以下示例使用 RetrieveEntityRequest 消息检索实体。 然后,该示例通过将 IsMailMergeEnabled 属性设置为 false 来更新该实体,从而禁用邮件合并,还在 UpdateEntityRequest 中将 HasNotes 设置为 true,以指定该实体应包括与 Annotation 实体的关系,以便实体能够显示备注。
RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = _customEntityName
};
RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
EntityMetadata BankAccountEntity = retrieveBankAccountEntityResponse.EntityMetadata;
// Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = new BooleanManagedProperty(false);
// Enable Notes
UpdateEntityRequest updateBankAccountRequest = new UpdateEntityRequest
{
Entity = BankAccountEntity,
HasNotes = true
};
_serviceProxy.Execute(updateBankAccountRequest);
Dim retrieveBankAccountEntityRequest As RetrieveEntityRequest = New RetrieveEntityRequest With {
.EntityFilters = EntityFilters.Entity,
.LogicalName = _customEntityName
}
Dim retrieveBankAccountEntityResponse As RetrieveEntityResponse = CType(_serviceProxy.Execute(retrieveBankAccountEntityRequest), RetrieveEntityResponse)
Dim BankAccountEntity As EntityMetadata = retrieveBankAccountEntityResponse.EntityMetadata
' Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = New BooleanManagedProperty(False)
' Enable Notes
Dim updateBankAccountRequest As UpdateEntityRequest = New UpdateEntityRequest With {
.Entity = BankAccountEntity,
.HasNotes = True
}
_serviceProxy.Execute(updateBankAccountRequest)
删除自定义实体
以下示例使用 DeleteEntityRequest 消息删除具有 _customEntityName 变量指定的逻辑名称的实体。
DeleteEntityRequest request = new DeleteEntityRequest()
{
LogicalName = _customEntityName,
};
_serviceProxy.Execute(request);
Dim request As New DeleteEntityRequest() With {.LogicalName = _customEntityName}
_serviceProxy.Execute(request)
另请参阅
使用示例和帮助程序代码
自定义实体元数据
创建和更新可通过电子邮件发送的实体
创建自定义实体。
Microsoft Dynamics 365
© 2017 Microsoft。 保留所有权利。 版权