locked
Entity doesn't contain attribute with Name RRS feed

  • Question

  • I have a dynamic marketing list which has 5 members of Account. I got the fetchXml and converted it to Query Expression using FetchXmlToQueryExpressionRequest class. now with the converted query expression i want to join 2 more entities using LinkEntity.

    The entities are like below.

    Account

    Subscription (has lookup of Account);
    ProductType (has lookup of Subscription);

    I have written the following code to join 

    QueryExpression queryExpression = conversionResponse.Query;

                LinkEntity new_subscription = new LinkEntity("account", "new_subscription", "accountid",
                                                                "new_accountid", JoinOperator.Inner);
                new_subscription.Columns = new ColumnSet("new_subscriptionid");
                new_subscription.EntityAlias = "subscription";
                queryExpression.LinkEntities.Add(new_subscription);


                LinkEntity new_producttype = new LinkEntity("new_subscription", "new_producttype",
                                                "new_subscriptionid", "new_subscriptionid", JoinOperator.Inner);
                new_producttype.Columns = new ColumnSet("new_resourcespecificationtypeid");
                new_producttype.EntityAlias = "producttype";
                queryExpression.LinkEntities.Add(new_producttype);

               var result = proxy.RetrieveMultiple(queryExpression);


    but it is showing an error 

    'Account' entity doesn't contain attribute with Name = 'new_subscriptionid'.

    if I comment out the below code

    LinkEntity new_producttype = new LinkEntity("new_subscription", "new_producttype",
                                                "new_subscriptionid", "new_subscriptionid", JoinOperator.Inner);
                new_producttype.Columns = new ColumnSet("new_resourcespecificationtypeid");
                new_producttype.EntityAlias = "producttype";
                queryExpression.LinkEntities.Add(new_producttype);

    then its fine. query is returning records. 
    What should be the actual code for this so that i can join multiple entities.

    Wednesday, March 30, 2016 10:16 AM

Answers

All replies