0

I need to write a service that connects to CRM, and returns with a list of all of the entity available on the server (custom or otherwise).

How can I do this? To be clear, I am not looking to return all data for all entities. Just a list of every type, regardless of whether any actually exist.

4

2 回答 2

3

You need to use 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
}

note that you will get also system or hidden entities, like wizardpage or recordcountsnapshot

于 2013-05-06T08:22:50.313 回答
1

You will probably find these sections of the MSDN useful:

于 2013-05-06T15:36:23.737 回答