Dynamics CRM 如何获取所有实体的列表
Dynamics CRM how to get list of all entities
使用 CRM 2013,如何通过 connectionManager
class 获取 CRM 中所有实体的列表?我想获取 所有 当前连接的实体。
如果您正在寻找使用代码 (C#) 获取实体元数据,那么我们有内置消息来获取所有实体,如果需要,还可以获取属性级别信息。您可以使用消息 "RetrieveAllEntitiesRequest"。示例代码如下以实现相同的目的。
RetrieveAllEntitiesRequest retrieveAllEntityRequest = new RetrieveAllEntitiesRequest
{
RetrieveAsIfPublished = true,
EntityFilters = EntityFilters.Attributes
};
RetrieveAllEntitiesResponse retrieveAllEntityResponse = (RetrieveAllEntitiesResponse)serviceProxy.Execute(retrieveAllEntityRequest);
如果您需要获取特定的实体信息,那么您可以使用消息"RetrieveEntityRequest"。同样的示例如下,
RetrieveEntityRequest entityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Attributes,
LogicalName = entityName,
RetrieveAsIfPublished = true
};
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)serviceProxy.Execute(entityRequest);
希望这就是您要找的。如果您需要更多信息,请告诉我们。
感谢您的评论并回答它现在有效,
这是我的功能
public static EntityMetadata[] GetEntities ( IOrganizationService organizationService)
{
Dictionary<string, string> attributesData = new Dictionary<string, string>();
RetrieveAllEntitiesRequest metaDataRequest = new RetrieveAllEntitiesRequest();
RetrieveAllEntitiesResponse metaDataResponse = new RetrieveAllEntitiesResponse();
metaDataRequest.EntityFilters = EntityFilters.Entity;
// Execute the request.
metaDataResponse = (RetrieveAllEntitiesResponse)organizationService.Execute(metaDataRequest);
var entities = metaDataResponse.EntityMetadata;
return entities;
}
我在 windows 应用程序表单中这样调用我的函数:
var allEntities = CRMHelpers.GetEntities(service);
foreach (EntityMetadata Entity in allEntities)
{
cbxEntity.Items.Add(Entity.LogicalName);
}
使用 CRM 2013,如何通过 connectionManager
class 获取 CRM 中所有实体的列表?我想获取 所有 当前连接的实体。
如果您正在寻找使用代码 (C#) 获取实体元数据,那么我们有内置消息来获取所有实体,如果需要,还可以获取属性级别信息。您可以使用消息 "RetrieveAllEntitiesRequest"。示例代码如下以实现相同的目的。
RetrieveAllEntitiesRequest retrieveAllEntityRequest = new RetrieveAllEntitiesRequest
{
RetrieveAsIfPublished = true,
EntityFilters = EntityFilters.Attributes
};
RetrieveAllEntitiesResponse retrieveAllEntityResponse = (RetrieveAllEntitiesResponse)serviceProxy.Execute(retrieveAllEntityRequest);
如果您需要获取特定的实体信息,那么您可以使用消息"RetrieveEntityRequest"。同样的示例如下,
RetrieveEntityRequest entityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Attributes,
LogicalName = entityName,
RetrieveAsIfPublished = true
};
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)serviceProxy.Execute(entityRequest);
希望这就是您要找的。如果您需要更多信息,请告诉我们。
感谢您的评论并回答它现在有效, 这是我的功能
public static EntityMetadata[] GetEntities ( IOrganizationService organizationService)
{
Dictionary<string, string> attributesData = new Dictionary<string, string>();
RetrieveAllEntitiesRequest metaDataRequest = new RetrieveAllEntitiesRequest();
RetrieveAllEntitiesResponse metaDataResponse = new RetrieveAllEntitiesResponse();
metaDataRequest.EntityFilters = EntityFilters.Entity;
// Execute the request.
metaDataResponse = (RetrieveAllEntitiesResponse)organizationService.Execute(metaDataRequest);
var entities = metaDataResponse.EntityMetadata;
return entities;
}
我在 windows 应用程序表单中这样调用我的函数:
var allEntities = CRMHelpers.GetEntities(service);
foreach (EntityMetadata Entity in allEntities)
{
cbxEntity.Items.Add(Entity.LogicalName);
}