0

为了掌握 MDS WCF API,我启动了一个 .Net Core 控制台应用程序。我正在努力寻找有关 API 中使用的数据结构的详细文档。我现在有一个简单的函数,它使用EntityMembersGet来读取某个实体的成员(行)。数据由 MDS 服务返回,但是当我尝试读取/显示数据时,我不知道如何显示域属性的值。为了显示属性的值,我使用EntityMembers.Members.Attributes[].Value当 Attribute 是 Freefrom 属性时它可以完美地工作。但是,当属性是域属性时,使用 EntityMembers.Members.Attributes[].Value 会返回“MDService.MemberIdentifier”。所以,我的问题是,如何获得域属性的值?

我已经分享了我的代码和输出。

作为第二个问题,如果有人能指出 MDS WCF API 的描述性文档比 MSDN 上的文档更具描述性,那就太好了。

 public static async Task ReadRecordsAsync()
    {
        EntityMembersGetRequest getRequest = new EntityMembersGetRequest();
        EntityMembersGetResponse getResponse = new EntityMembersGetResponse();

        EntityMembersGetCriteria membersGetCriteria = new EntityMembersGetCriteria
        {
            ModelId = new Identifier() { Name = "Model1" },
            EntityId = new Identifier() { Name = "Entity1" },
            VersionId = new Identifier() { Name = "VERSION_1" },
            MemberType = MemberType.Leaf,
            MemberReturnOption = MemberReturnOption.DataAndCounts
        };

        getRequest.MembersGetCriteria = membersGetCriteria;
        //EntityMembersGetResponse getResponse = await mdsProxy.EntityMembersGetAsync(getRequest);
        getResponse = await mdsProxy.EntityMembersGetAsync(getRequest);

        Console.WriteLine("Member information: \n Membercount: {0} | TotalPages: {1}", getResponse.EntityMembersInformation.MemberCount, getResponse.EntityMembersInformation.TotalPages);
        //Console.WriteLine("Members: \n Count: {0}", getResponse.EntityMembers.Members.Count.ToString());

        if (getResponse.EntityMembers.Members.Count > 0)
        {              
            foreach (Member individualMember in getResponse.EntityMembers.Members)
            {
                Console.WriteLine("----------");
                Console.WriteLine("Individual Member: \n Id: {0} | Code: {1} | Name: {2}",
                    individualMember.MemberId.Id, 
                    individualMember.MemberId.Code,
                    individualMember.MemberId.Name);
                for (int i = 0; i < individualMember.Attributes.Count; i++)
                {
                    Console.WriteLine("Attributes ({0}): \n Id Id: {1} | Id name: {2} | Type: {3} | Value: {4} \n ",
                        i,
                        individualMember.Attributes[i].Identifier.Id,
                        individualMember.Attributes[i].Identifier.Name,
                        individualMember.Attributes[i].Type,
                        individualMember.Attributes[i].Value
                        );
                    if (individualMember.Attributes[i].Type == AttributeValueType.Domain)
                    {
                        Console.WriteLine("Domain attribute");
                    }
                }
            }

运行应用程序时的输出:参见“属性 (2)”行末尾的域属性输出。


Member information:
 Membercount: 3 | TotalPages: 1
----------
Individual Member:
 Id: 655b4f56-8a03-47cc-bbdd-311d0103a97e | Code: Code1 | Name: Naam1
Attributes (0):
 Id Id: bc2a8c6d-bf50-41b5-bef5-4170949ec93c | Id name: No. | Type: String | Value: No.1

Attributes (1):
 Id Id: bb71e279-74ce-4131-a56a-f7be884d6067 | Id name: Description | Type: String | Value: Desc1

Attributes (2):
 Id Id: 5db1b524-c2ec-47ff-8d74-399859c6fed0 | Id name: UnitOfMeasure | Type: Domain | Value: MDService.MemberIdentifier

Domain attribute
----------
Individual Member:
 Id: d3fc1b10-30ee-4546-9b75-5c9c89c3fd00 | Code: Code2 | Name: Naam2
Attributes (0):
 Id Id: bc2a8c6d-bf50-41b5-bef5-4170949ec93c | Id name: No. | Type: String | Value: No.2

Attributes (1):
 Id Id: bb71e279-74ce-4131-a56a-f7be884d6067 | Id name: Description | Type: String | Value: Desc2

Attributes (2):
 Id Id: 5db1b524-c2ec-47ff-8d74-399859c6fed0 | Id name: UnitOfMeasure | Type: Domain | Value: MDService.MemberIdentifier

Domain attribute
----------
4

1 回答 1

0

通过 GitHub 上的 SQL 功能示例,我找到了我的问题的答案。当属性是 Domain 属性时,您可以使用 MemberIdentifier 类来获取属性的属性:

if (Attribute.Type == AttributeValueType.Domain)
{
   MemberIdentifier dbaMemberId = (MemberIdentifier)anAttribute.Value;
   Console.WriteLine("Attribute Value:{0}", dbaMemberId.Code);
}

我希望这可以帮助其他人寻找此类信息。

编辑:这是GitHub 上示例的链接

于 2018-04-27T08:32:52.757 回答