如何使用主数据服务(MDS)WCF API获取域属性的值



要获取MDS WCF API的握把我启动了.NET Core Console应用程序。我很难找到有关API中使用的数据结构的详细文档。我现在有一个简单的功能,它使用 entityMembersget 读取某个实体的成员(行(。数据由MDS服务返回,但是当我尝试读取/显示数据时,我无法弄清楚如何显示域属性的值。要显示属性的值,我使用 entitymembers.members.attributes []。value ,当属性是freefrom属性时,它可以很好地工作。但是,当属性是一个域属性时,EntityMembers.members.attributes []。值返回" mdservice.memberidentifier"。所以,我的问题是,如何获得域属性的值?

我共享了我的代码和输出。

作为次要问题,如果有人可以指向MDS WCF API的描述性文档,那将是很棒的。

 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
----------

浏览github上SQL的功能样本,我找到了我问题的答案。当属性是域属性时,您可以使用成员识别符类获取属性的属性:

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

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

edit :这是Github上的样本

上的链接

相关内容

  • 没有找到相关文章

最新更新