locked
Retriving Related Entities along with Entities RRS feed

  • Question

  •  Hi,

         This may sound little dumb but I am really struck here. I am trying to retrive entities and relatedentities  in one result set. as we know in entity collection for each entity we will be having a related entity property,  I was expecting that  even related entities will get retrieved along with entities, But there is nothing in related entities, but one thing I observed is, only records which got parent entity got retrieved.

    following is code 

     
      QueryExpression query = new QueryExpression()
                    {
                        EntityName = "entity",
                        ColumnSet = new ColumnSet(true),
                        LinkEntities =
                            {
                                new LinkEntity
                                {
                                    Columns=new ColumnSet(true),
                                    LinkFromEntityName = "new_entity",
                                    LinkFromAttributeName = "new_parententity",
                                    LinkToEntityName = "new_entity2",
                                    LinkToAttributeName = "gti_entity2id",
    
                                    LinkCriteria = new FilterExpression
                                    {
                                        FilterOperator = LogicalOperator.And,
                                        Conditions =
                                        {
                                            new ConditionExpression
                                            {
                                                AttributeName = "new_parententity",
                                                Operator = ConditionOperator.NotNull
                                               
                                            }
                                        }
                                    }
                                },
                                
                            },
                    };
    
                    // Obtain results from the query expression.
                    EntityCollection ec = _orgserviceproxy.RetrieveMultiple(query);


    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.


    Wednesday, March 9, 2016 11:15 AM