web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get N:N relation records in C#

(0) ShareShare
ReportReport
Posted on by 1,562

Hello Team,

I have created a custom entity with N:N relation(User_CustomEntityRelation) with user entity.

Now I have assigned records by look-up filed .But don't know how i can get by using C# code.Please suggest me.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello Rahul,

    Check SDK it have sample codes: msdn.microsoft.com/.../gg328446.aspx

    rajeevpentyala.wordpress.com/.../retrieve-associated-records-nn-related

    Thanks

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at
  • Tin Profile Picture
    1,562 on at

    Thanks for the help.

    But I am not understanding the logic,how can i get data from entities.

    entity 1 ---Config

    entity 2 ---Users

    N:N Realtion --- new_new_config_systemuser

    Please suggest me how i can get data from Config entity,which is on subgrid via n:n realtion.

  • Mahendar Pal Profile Picture
    45,095 on at

    Did you check the post and have written any code ?? share your code what you have written and where you have written.

  • Suggested answer
    sharma.sandeep82 Profile Picture
    743 on at

    Hi Rahul,

    Please go through the below URL.

    ssharmacrm.wordpress.com/.../accessing-the-intersection-entity-in-dynamics-crm-plugin

    Hope it will help you.

    --

    Thanks

    Sandeep Sharma

  • Tin Profile Picture
    1,562 on at

    string entity1 = "systemuser";

               string entity2 = "slaconfig";

               string relationshipEntityName = "new_new_slaconfig_systemuser";

               QueryExpression query3 = new QueryExpression(entity1);

               query3.ColumnSet = new ColumnSet(true);

               LinkEntity linkEntity1 = new LinkEntity(entity1, relationshipEntityName, "systemuserid", "{systemuserid}", JoinOperator.Inner);

               LinkEntity linkEntity2 = new LinkEntity(relationshipEntityName, entity2, "new_slaconfigid", "{new_slaconfigid}", JoinOperator.Inner);

               linkEntity1.LinkEntities.Add(linkEntity2);

               query3.LinkEntities.Add(linkEntity1);

               // Add condition to match the Bike name with “Honda”

               // linkEntity2.LinkCriteria = new FilterExpression();

               // linkEntity2.LinkCriteria.AddCondition(new ConditionExpression("raj_bikename", ConditionOperator.Equal, "Honda"));

               EntityCollection collRecords = crmService.RetrieveMultiple(query3);

    Please let me know where i am doing wrong

  • Suggested answer
    Surmeet Singh Profile Picture
    3,075 on at

    Hi Rahul,

    The best and easiest way is to use fetchXML. You can create your query via advanced find and moreover no such complex programming is required.

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at

    Hi Rahul,

    Please check below links,

    social.microsoft.com/.../crm-2011-onpremise-problem-setting-up-lookup-field-in-c-plugin

    Thanks

  • Tin Profile Picture
    1,562 on at

    string entity1 = "systemuser";

              string entity2 = "slaconfig";

              string relationshipEntityName = "new_new_slaconfig_systemuser";

              QueryExpression query3 = new QueryExpression(entity1);

              query3.ColumnSet = new ColumnSet(true);

              LinkEntity linkEntity1 = new LinkEntity(entity1, relationshipEntityName, "systemuserid", "{systemuserid}", JoinOperator.Inner);

              LinkEntity linkEntity2 = new LinkEntity(relationshipEntityName, entity2, "new_slaconfigid", "{new_slaconfigid}", JoinOperator.Inner);

              linkEntity1.LinkEntities.Add(linkEntity2);

              query3.LinkEntities.Add(linkEntity1);

              // Add condition to match the Bike name with “Honda”

              // linkEntity2.LinkCriteria = new FilterExpression();

              // linkEntity2.LinkCriteria.AddCondition(new ConditionExpression("raj_bikename", ConditionOperator.Equal, "Honda"));

              EntityCollection collRecords = crmService.RetrieveMultiple(query3);

    above code is working fine but i want to get all columns from both the entity .how can i do.?

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans