简体   繁体   English

获取 Dynamics CRM 中的所有实体元数据

[英]Get ALL Entity Metadata in Dynamics CRM

What I want to do is:我想做的是:

  1. Retrieve all metadata from CRM.从 CRM 中检索所有元数据。
  2. Serialize that metadata and store it in a file.序列化该元数据并将其存储在文件中。
  3. At a later point, deserialize and eed that metadata to XrmFakeEasy for unit tests.稍后,反序列化该元数据并将其提供给 XrmFakeEasy 以进行单元测试。

Steps 2 and 3 are done but I don't know how to accomplish step 1. I've spent some time noodling around in the code and on Google but remain stumped.第 2 步和第 3 步已完成,但我不知道如何完成第 1 步。我花了一些时间在代码和 Google 上闲逛,但仍然感到困惑。

We're using.Net so what I need is to read ALL the Entity Metadata (type: Microsoft.Xrm.Sdk.Metadata.EntityMetadata).我们正在使用.Net,所以我需要读取所有实体元数据(类型:Microsoft.Xrm.Sdk.Metadata.EntityMetadata)。

If anyone knows how to do this or can point me in the direction of the API (I haven't been able to find one) then please let me know.如果有人知道如何做到这一点,或者可以将我指向 API 的方向(我一直找不到),请告诉我。

PS This case is for on-premise crm. PS 此案例适用于本地 crm。

If I get it right you need to use RetrieveAllEntitiesRequest request.如果我做对了,您需要使用 RetrieveAllEntitiesRequest 请求。 Here are more details: https://stackoverflow.com/a/29694213/2575544以下是更多详细信息: https://stackoverflow.com/a/29694213/2575544

For the benefit of anyone that comes across this post here's为了任何遇到这篇文章的人的利益,这里是

My final solution我的最终解决方案

public static EntityMetadata[] GetMetadata(IOrganizationService crmService)
{
    var request = new RetrieveAllEntitiesRequest
    {
        EntityFilters = EntityFilters.All
    };

    var response = (RetrieveAllEntitiesResponse) crmService.Execute(request);
    return response.EntityMetadata;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM