问题描述
我在CRM 2011中有两个实体 - emailmatchingrule和emailmatchingrulefield,在标准的亲子关系中.我要检索的是所有规则的集合,每个规则的所有字段都被预先挑选为相关实体.
这甚至可能吗?我可以使用查询表达addlinkentity功能获得一个扁平的列表,但这并不是我真正追求的.
使用早期绑定的实体和LINQ,我只能弄清楚如何获取每个列表,但没有相关项目.
有什么想法?
tia
推荐答案
您的LINQ语句需要使用" include".
from rule in EmailMatchingRule.Include("EmailMatchingRuleField") select rule
您将获得的规则集合将拥有所有匹配规则,现在已经急切地加载了.
问题描述
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
推荐答案
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.