0
我需要編寫一個連接到CRM的服務,並返回服務器上可用的所有實體(自定義或其他)的列表。如何發現所有實體類型?一人一個?
我該怎麼做?要清楚,我是而不是希望返回所有實體的所有數據。只需列出每種類型,不管是否存在任何類型。
我需要編寫一個連接到CRM的服務,並返回服務器上可用的所有實體(自定義或其他)的列表。如何發現所有實體類型?一人一個?
我該怎麼做?要清楚,我是而不是希望返回所有實體的所有數據。只需列出每種類型,不管是否存在任何類型。
您需要使用RetrieveAllEntitiesRequest
RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest()
{
EntityFilters = EntityFilters.Entity,
RetrieveAsIfPublished = true
};
// service is the IOrganizationService
RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)service.Execute(request);
foreach (EntityMetadata currentEntity in response.EntityMetadata)
{
string logicalName = currentEntity.LogicalName;
// your logic here
}
請注意,您還可以得到系統或隱藏的實體,像wizardpage
或recordcountsnapshot
你也許會發現在MSDN有用的這些部分:
這正是我最終做的! – 2013-05-06 18:22:43