посмотрев в SDK статью по
RetrieveAllEntities, можно состряпать такой вот метод:
Код:
private string GetEntityName(int EntityTypeCode)
{
// Create an authentication token.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "AdventureWorksCycle";
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for AD Authentication.
token.AuthenticationType = 0;
// Create the metadata Web service;
MetadataService service = new MetadataService();
service.Url = "http://<servername>:<port>/MSCRMServices/2007/MetadataService.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.PreAuthenticate = true;
// Create the request
RetrieveAllEntitiesRequest allEntitiesRequest = new RetrieveAllEntitiesRequest();
allEntitiesRequest.RetrieveAsIfPublished = true;
allEntitiesRequest.MetadataItems = MetadataItems.EntitiesOnly;
// Execute the request
RetrieveAllEntitiesResponse allEntitiesResponse = (RetrieveAllEntitiesResponse)service.Execute(allEntitiesRequest);
// Iterate through the retrieved entities
foreach (EntityMetadata entity in allEntitiesResponse.CrmMetadata)
{
if (entity.ObjectTypeCode.Value == EntityTypeCode)
{
return entity.LogicalName;
}
}
return String.Empty;
}