Udostępnij za pośrednictwem


Retrieve records for many-to-many relationships using intersect entities

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

In Microsoft Dynamics 365 and Microsoft Dynamics 365 (online), when there is a many-to-many (N:N) relationship between two entities, an intersect entity is automatically created. This is true for both system relationships built into the product as well as custom many-to-many relationships. The name of the entity is specified in the IntersectEntityName property in the relationship metadata. The name of the relationship is specified in the SchemaName property in the relationship metadata.

You can use the intersect entities to refine the result set in any query by using the IOrganizationService.RetrieveMultiple method or the RetrieveMultipleRequest message. However, you cannot retrieve the intersect entity records directly by using the QueryExpression class. To retrieve the records in an intersect entity, you must use the FetchExpression class.

In this topic

Intersect entities

Intersect entity metadata

Intersect entities

The following table lists the intersect entities that are used in N:N relationships between default entities.

IntersectEntity

MtoM_SchemaName

MtoM_Entity1

MtoM_Entity2

accountleads

accountleads_association

account

lead

campaignactivityitem

campaignactivitylist_association

campaignactivity

list

campaignactivityitem

campaignactivitysalesliterature_association

campaignactivity

salesliterature

campaignitem

campaigncampaign_association

campaign

campaign

campaignitem

campaignlist_association

campaign

list

campaignitem

campaignproduct_association

campaign

product

campaignitem

campaignsalesliterature_association

campaign

salesliterature

competitorproduct

competitorproduct_association

competitor

product

competitorsalesliterature

competitorsalesliterature_association

salesliterature

competitor

connectionroleassociation

connectionroleassociation_association

connectionrole

connectionrole

contactinvoices

contactinvoices_association

invoice

contact

contactleads

contactleads_association

contact

lead

contactorders

contactorders_association

salesorder

contact

contactquotes

contactquotes_association

quote

contact

entitlementcontacts

entitlementcontacts_association

contact

entitlement

entitlementproducts

product_entitlement_association

product

entitlement

entitlementtemplateproducts

product_entitlementtemplate_association

product

entitlementtemplate

leadcompetitors

leadcompetitors_association

lead

competitor

leadproduct

leadproduct_association

lead

product

listmember

listaccount_association

list

account

listmember

listcontact_association

list

contact

listmember

listlead_association

list

lead

opportunitycompetitors

opportunitycompetitors_association

opportunity

competitor

productassociation

productassociation_association

product

product

productsalesliterature

productsalesliterature_association

product

salesliterature

productsubstitute

productsubstitute_association

product

product

queuemembership

queuemembership_association

queue

systemuser

roleprivileges

roleprivileges_association

privilege

role

roletemplateprivileges

roletemplateprivileges_association

roletemplate

privilege

servicecontractcontacts

servicecontractcontacts_association

contact

contract

subscriptionmanuallytrackedobject

contact_subscription_association

subscription

contact

subscriptionmanuallytrackedobject

task_subscription_association

subscription

task

systemuserprofiles

systemuserprofiles_association

systemuser

fieldsecurityprofile

systemuserroles

systemuserroles_association

systemuser

role

teammembership

teammembership_association

team

systemuser

teamprofiles

teamprofiles_association

team

fieldsecurityprofile

teamroles

teamroles_association

team

role

Intersect entity metadata

Most intersect entities are simple, containing just the few properties that are needed to provide a link between to two entities in the N:N relationship. If you are using early bound types, you can see an example, in the ContactInvoices intersect entity. This is the case for all custom many-to-many relationships. However, there are several intersect entities that have additional properties that are used for specific functionality for the relationship. To make it easier to write queries by using the special intersect entities, the attribute metadata is provided in the following topics:

See Also

Build queries with QueryExpression
Customize entity relationship metadata
Retrieve data with queries using SDK assemblies
CampaignActivityItem intersect entity metadata
CampaignItem intersect entity metadata
ListMember intersect entity metadata
Role Privileges intersect entity metadata
Sample: Retrieve records from an intersect table

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright