为了掌握MDS WCF API,我启动了一个.Net Core控制台应用程序。我很难找到有关API中使用的数据结构的详细文档。 我现在有一个简单的函数,它使用 EntityMembersGet 来读取某个实体的成员(行)。 MDS服务返回数据,但是当我尝试读取/显示数据时,我无法弄清楚如何显示域属性的值。要显示属性的值,我使用 EntityMembers.Members.Attributes []。值,当属性是Freefrom属性时,它可以正常工作。但是,当Attribute是Domain属性时,使用EntityMembers.Members.Attributes []。Value返回“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");
}
}
}
运行应用程序时的输出:请参阅Domain属性输出的“Attributes(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
----------
答案 0 :(得分:0)
在GitHub上浏览SQL的Feature示例,我找到了问题的答案。 当属性是Domain属性时,您可以使用MemberIdentifier类来获取属性的属性:
if (Attribute.Type == AttributeValueType.Domain)
{
MemberIdentifier dbaMemberId = (MemberIdentifier)anAttribute.Value;
Console.WriteLine("Attribute Value:{0}", dbaMemberId.Code);
}
我希望这有助于其他人寻找此类信息。
编辑:这是GitHub
上示例的链接