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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

[C#] How get relations with QueryExpression?

(0) ShareShare
ReportReport
Posted on by 165

Hello.

I have problem:

I  have entity (Contact,  id=1)  has relation to Account (id=2),  and this Account relates on other Account (Parent Account,  id=3).

So: Contact (parent) ->Account ->Account

I have to write QueryExpression to get information about all these 3 entities.

I have 2 questions:

(1) How can I tell QueryExpression to get info from related objects with 2 levels of relation?

(2) I've heard about these objects: 'LinkedEntity' and 'Relationship'. Maybe, Relationship is outdated object.

What should I use in my sample?

Please, help me.

Thank you

  • Suggested answer
    PabloCRP Profile Picture
    1,088 on at

    Hi, You should use LinkedEntity, Link Contact to parent account -> to child's accounts. 

    Relationship object is used to represents the relationship of the entities.

    You might take a look at:

    https://docs.microsoft.com/es-es/dotnet/api/microsoft.xrm.sdk.query.queryexpression?view=dynamics-general-ce-9

  • LeonardBertone Profile Picture
    165 on at

    Thank you!

    I have Contact->Account->ParentAccount(Account entity) relation model.

    How canI get info about ParentAccount?

    It's the  2 level depth in relations for Contact entity.

    Is it possible?

    Thank you

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans