Matt
Matt

Reputation: 1370

Retrieve a list of entites from CRM 2011, each with all of their related entities

I have two entities in CRM 2011 - EmailMatchingRule and EmailMatchingRuleField, in a standard parent-child relationship. What I want to retrieve is a set of all of the rules, each with all of its fields pre-fetched as related entities.

Is this even possible? I can get a flattened list using the QueryExpression AddLinkEntity functionality, but that's not really what I'm after.
Using early bound entities and Linq, I can only figure out how to get a list of each, but without the related items.

Any thoughts ?

TIA

Upvotes: 2

Views: 1760

Answers (1)

kareem
kareem

Reputation: 773

Your linq statement needs to use an "Include".

from rule in EmailMatchingRule.Include("EmailMatchingRuleField")
select rule

The collection of rules you'll get back will have all the matching rules now already eagerly loaded.

Upvotes: 1

Related Questions