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)

difference between Fetch XML and Query Expression

(0) ShareShare
ReportReport
Posted on by 1,562

Hi all,

Can anyone tell me what is difference between Fetch XML and Query Expression. 

Someone told me Query Expression wont allowed Association(Joins).

But i had did association by using query expression.

Yes,I am correct please let me know the main difference why we are using Query Expressionand why we use Fetch XML

I am using following link:   msdn.microsoft.com/.../dn481591.aspx

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    normally they are equivalent (meaning that a fetchxml can be converted to queryexpression and vice versa)

    fetchxml has a couple of nice additions (like aggregation and get the text value of lookups and optionset directly)

    who told you that query expression don't allow joins is wrong

  • Tin Profile Picture
    1,562 on at

    Hi Guido,

    If both are almost same so how can we decide which one we have to use and when .

    Is there some specific difference?

    That guy told me aggregation will not happen in query expression and its done by fetch xml only.

  • Guido Preite Profile Picture
    54,086 Moderator on at

    you decide by your project and the experience.

    of course if you need aggregation you will use fetchxml, if you need to add Criteria conditions dynamically in the code it's easier with QueryExpression.

    you can use both, so try which one is more suitable for your project.

  • suresh maurya Profile Picture
    630 on at

    For testing of FetchXML, you can test here online http://msxrmtools.com

  • Community Member Profile Picture
    on at

    Hi Tin,

    As said by Guido Preite, fetchXml is used when you need aggregate function. Also, it is easy to generate FetchXml, from advance find.

    In the background, at run time, Query Expression will also get converted into fetchXml. So, fetchXml is recommended when performance is concerned.

  • joman Profile Picture
    617 on at

    Query Expression allow joins:

    Look LinkEntity here: msdn.microsoft.com/.../gg328149.aspx

  • Guido Preite Profile Picture
    54,086 Moderator on at

    @Satya Salikanti,

    can you indicate a reference where is indicated that Query Expressions are converted to fetchxml in the background and for performance they are suggested?

  • ram r Profile Picture
    on at

    AFAIK, Both are almost similar expect that fetchxml provides more flexibility as it supports aggregation.

    Personally, I felt fetchxml is better than queryexpression when it comes to complex queries with multiple linked entities. Also aggregation is something very handy so I prefer fetch.

    When it comes to platform, during 2011 the behavior I observed in retrievemultiple is "queryexpression is used on webapplication views"  and "fetchxml on outlook views". But now, I am not really sure how it works or converts internally. However the performance impact was very minimal up to my knowledge due to platform conversions.

  • Community Member Profile Picture
    on at

    Hi Guido,

    I don't have any reference, but this is the conclusion we came to among our project mates; As we send the fetchXML or Query Expression to WebService call, and web service calls can only take in XML input, eventually, the query expression should get converted into xml format during run time. As the conversion time will be saved if use fetchXml directly, suggested for performance.

  • Guido Preite Profile Picture
    54,086 Moderator on at

    so if you don't have references, you should not make assumptions about internal conversions between QueryExpression and FetchXml or performance.

    WebServices can take input in different formats, not only in XML.

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