-->

Understanding Link-entity in FetchXML

2020-03-07 10:16发布

问题:

I understand <link-entity> is used to do joins, but can you help me translate the following into english?

<entity name = "example">

*insert a bunch of attributes*

     <link-entity name="providercertification" from="providerid" to="vendorid" alias="aa">

I understand <link-entity> is used for joins, but the join type is not specified, so that is throwing me off. How does the link-entity work if no join type is specified? Is it automatically an inner join?

Also, which column does the from part apply to? The very first entity or the one specified in the <link-entity>?

Same question for the from part.

回答1:

Per documentation the below query is totally valid, which means alias, from & link-type are optional.

from always refer to same entity as link-entity node (primary key systemuserid of systemuser in this case). to refers to attribute of entity parent node (owninguser of account in this case)

   <entity name='account'>   
      <attribute name='accountid'/>   
      <attribute name='name'/>   
      <link-entity name='systemuser' to='owninguser'>   

Use a left outer join in FetchXML to query for records "not in"

So explicit link-type='outer' is required for outer join but inner join is default.

Interestingly Fetchxml is full of surprises. You can also refer FetchXML schema