locked
can anybody explain me what is link entity in dynamics crm 2013 RRS feed

  • Question

  • link entity class has some parameters linkfromentityname,toentityname fromattributename, toattributename.can anyone explain me.i'm trying to retrieve the n:n relationship in an entity using linkentity.

    hsk srinivas

    Thursday, June 19, 2014 11:09 AM

Answers

  • Thanks man.i got it u posted the above blog is usefull

    hsk srinivas

    • Marked as answer by Ppandu Thursday, June 19, 2014 1:56 PM
    Thursday, June 19, 2014 1:53 PM

All replies

  • Hi,

    Using LinkEntity you can basically "join" two entities. This allows you to fetch data from a related entity record. You can have multiple LinkEntitites in your QueryExpressions, thus enabling you to basically join multiple entities with the single entity you're executing your QueryExpression on.

    From the MSDN article:

    • LinkFromAttributeName - Gets or sets the logical name of the attribute of the entity that you are linking from.
    • LinkFromEntityName - Gets or sets the logical name of the entity that you are linking from.
    • LinkToAttributeName - Gets or sets the logical name of the attribute of the entity that you are linking to.
    • LinkToEntityName - Gets or sets the logical name of the entity that you are linking to.

    This blog will help you use LinkEntity for a N:N relationship: http://bernado-nguyen-hoan.com/2014/04/19/retrieving-related-records-in-an-nn-relationship-using-queryexpression/


    Admin QuikView Solution for CRM 2013

    • Proposed as answer by Anupam Bishui Thursday, June 19, 2014 6:03 PM
    Thursday, June 19, 2014 11:14 AM
  • if (context.InputParameters.Contains("Target") && (context.InputParameters["Target"]) is Entity)
                {
                    Entity en = (Entity)context.InputParameters["Target"];
                    QueryExpression qx = new QueryExpression("lead");
                    qx.ColumnSet = new ColumnSet(true);
                    //LinkEntity linkEntity1 = new LinkEntity("lead", "new_lead_transactioncurrency", "leadid", "transactioncurrencyid", JoinOperator.Inner);
                    //  LinkEntity linkEntity2 = new LinkEntity("new_lead_transactioncurrency", "transactioncurrency", "transactioncurrencyid", "transactioncurrency", JoinOperator.Inner);
                    LinkEntity linkEntity1 = new LinkEntity("lead", "new_lead_transactioncurrency", "leadid", "leadid", JoinOperator.Inner);
                    LinkEntity linkEntity2 = new LinkEntity("new_lead_transactioncurrency", "transactioncurrency", "transactioncurrencyid", "transactioncurrencyid", JoinOperator.Inner);
                    linkEntity1.LinkEntities.Add(linkEntity2);
                    qx.LinkEntities.Add(linkEntity1);
                    EntityCollection entitycollect = service.RetrieveMultiple(qx);
                    var xxx = entitycollect.Entities.Count;
                }
    i'm trying to retrieve associated n:n relationship using the above code.in where i'm getting wrong.shall i use metadata browser.



    hsk srinivas

    Thursday, June 19, 2014 11:39 AM
  • Hi,

    Could you please tell us what you're trying to retrieve? Then we could provide the correct code.


    Admin QuikView Solution for CRM 2013

    Thursday, June 19, 2014 11:56 AM
  • i have two entites lead and transactioncurrency.  transactioncurrency is associated with the lead (n:n  relationship).now i'm trying to retrieve the associated currencies in lead.but i'm unable to get the result.above is my code could you have references.

    hsk srinivas

    Thursday, June 19, 2014 12:44 PM
  • Thanks man.i got it u posted the above blog is usefull

    hsk srinivas

    • Marked as answer by Ppandu Thursday, June 19, 2014 1:56 PM
    Thursday, June 19, 2014 1:53 PM