對於實體類型的分段解決方案組件更多信息必須加入到與DoNotIncludeSubcomponents
選項設置爲true
解決方案。然後,可以將實體的不同部分逐個添加到解決方案中。
其中實體「賬戶」被添加到解決方案「測試」,只有屬性「ACCOUNTNUMBER」舉個例子:
private static EntityMetadata RetrieveEntity(string entityName, IOrganizationService service)
{
var request = new RetrieveEntityRequest
{
LogicalName = entityName,
EntityFilters = EntityFilters.All,
RetrieveAsIfPublished = true
};
return ((RetrieveEntityResponse)service.Execute(request)).EntityMetadata;
}
private static void AddEntityComponent(Guid componentId, int componentType, string solutionName, IOrganizationService service)
{
var request = new AddSolutionComponentRequest
{
AddRequiredComponents = false,
ComponentId = componentId,
ComponentType = componentType,
DoNotIncludeSubcomponents = true,
SolutionUniqueName = solutionName
};
service.Execute(request);
}
IOrganizationService service = factory.CreateOrganizationService(null);
EntityMetadata entity = RetrieveEntity("account", service);
AddEntityComponent(entity.MetadataId.Value, 1, "Test", service);
AddEntityComponent(entity.Attributes.First(a => a.LogicalName == "accountnumber").MetadataId.Value, 2, "Test", service);
你的回答解決了補丁的解決方案,而不是分割的解決方案。 –