locked
I have an entity in MDS with a large number of attributes. I have successfully used EntityMembersGet to retrieve all attributes of all members of the Entity. I need a code example of how to retrieve only select attributes all entity members. RRS feed

  • Question

  • I have an entity in MDS with a large number of attributes.  I have successfully used EntityMembersGet to retrieve all attributes of all members of the Entity.  I need a code example or description of how to retrieve only select attributes(a subset of the attributes) of all entity members.


    HM


    Saturday, October 5, 2013 8:46 PM

Answers

  • You want: EntityMembersGetCriteria.Attributes

    Also check out this helper class: MDSEntityCRUDOperations which has some simplifying wrapper functions for reading and writing MDS entities.  As you've probably noticed, dealing directly with the web service proxy types leads to a bunch of boilerplate code.

    David


    David http://blogs.msdn.com/b/dbrowne/

    • Proposed as answer by Elvis Long Sunday, October 13, 2013 11:28 AM
    • Marked as answer by HenrytonMariner Tuesday, October 15, 2013 3:59 PM
    Saturday, October 5, 2013 11:56 PM

All replies

  • You want: EntityMembersGetCriteria.Attributes

    Also check out this helper class: MDSEntityCRUDOperations which has some simplifying wrapper functions for reading and writing MDS entities.  As you've probably noticed, dealing directly with the web service proxy types leads to a bunch of boilerplate code.

    David


    David http://blogs.msdn.com/b/dbrowne/

    • Proposed as answer by Elvis Long Sunday, October 13, 2013 11:28 AM
    • Marked as answer by HenrytonMariner Tuesday, October 15, 2013 3:59 PM
    Saturday, October 5, 2013 11:56 PM
  • Hi  Henryton,

    check out below sample code snippet.This is very generic,let us know if you have specific requirement and we can help you in that.

            public void getFilteredEntityMembers()
            {
                var filteredAttributes = new List<Identifier>();
                var opr = new OperationResult();
                var Totalem = new EntityMembers();
                var memr = new List<Member>();
                var einfo = new EntityMembersInformation();
    
                //attribute specification 
                var attributeSpec = new MemberAttributeIdentifier() {
    
                    MemberId = new MemberIdentifier() { Code = "anuptest119" },
                    Name = "TestString"
                };
    
    
                //ad more specifications if required, this will get only attribute whose name is "TestString"
                filteredAttributes.Add(attributeSpec);
    
                //setting criteria 
                EntityMembersGetCriteria entityGet = new EntityMembersGetCriteria()
                {
                    EntityId = new Identifier() { Name = "TestEntity2" },
                    ModelId = new Identifier() { Name = "AnupTestModel" },
                    VersionId = new Identifier() { Name = "VERSION_1" },
                    Attributes = filteredAttributes.ToArray()
                };
    
                //This limits the tool to export import 2000 only 
                entityGet.PageSize = 2000;
                entityGet.MemberReturnOption = MemberReturnOption.DataAndCounts;
                Totalem = _mdsProxy.EntityMembersGet(new International(), entityGet, out einfo, out opr);
    
                for (int x = 1; x <= einfo.TotalPages; x++)
                {
                    entityGet.PageNumber = x;
                    EntityMembers emi = _mdsProxy.EntityMembersGet(new International(), entityGet, out einfo, out opr);
                    memr.AddRange(emi.Members);
                    if (x == 1) Totalem = emi;
    
    
                }
    
                Totalem.Members = memr.ToArray();
    
    
    
            }
    
                                                


    • Proposed as answer by Elvis Long Sunday, October 13, 2013 11:28 AM
    Monday, October 7, 2013 12:03 PM
  • David, thanks.  Turns out my code was correct except that I misspelled the name of one attribute which then caused no attributes to be returned.


    HM

    Tuesday, October 15, 2013 4:01 PM