c# - Why does LoadProperty not load the related entities for 1:N relationships? (CRM2011, early binding entity classes) -
suppose have custom entity new_someentity
has 2 other related entities: "owner" entity i'll call new_ownerentity
(this n:1 relationship) , "child" entity i'll call new_childentity
(1:n relationship).
i'm attempting populate related entities calling loadproperty
:
new_someentity en = context.new_someentityset.first(); context.loadproperty(en, "new_someentity_new_ownerentity"); context.loadproperty(en, "new_someentity_new_childentity");
afterward, en.new_someentity_new_ownerentity
populated expect reference owner entity, en.new_someentity_new_childentity
still null. no errors produced.
what's deal?
on side note, there not concise way load related entity ienumerable of entities without needing use loadproperty
on each entity individually? seems pretty classic case of n+1 queries issue.
just because think should return empty list when object doesn't have child entities doesn't mean that's way loadproperty works.
so else comes upon this:
loadproperty leave property null when there aren't related records record, on 1:n relationships.
Comments
Post a Comment