public ResolvedEntityReferenceSet FetchResolvedEntityReferences(ResolveOptions resOpt = null) { bool wasPreviouslyResolving = this.Ctx.Corpus.isCurrentlyResolving; this.Ctx.Corpus.isCurrentlyResolving = true; if (resOpt == null) { resOpt = new ResolveOptions(this, this.Ctx.Corpus.DefaultResolutionDirectives); } // this whole resolved entity ref goo will go away when resolved documents are done. // for now, it breaks if structured att sets get made. resOpt = CdmObjectBase.CopyResolveOptions(resOpt); resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> { "normalized", "referenceOnly" }); ResolveContext ctx = this.Ctx as ResolveContext; // what it actually is ResolvedEntityReferenceSet entRefSetCache = ctx.FetchCache(this, resOpt, "entRefSet") as ResolvedEntityReferenceSet; if (entRefSetCache == null) { entRefSetCache = new ResolvedEntityReferenceSet(resOpt); if (resolvingEntityReferences == false) { resolvingEntityReferences = true; // get from dynamic base public class and then 'fix' those to point here instead. CdmObjectReference extRef = this.ExtendsEntityRef; if (extRef != null) { var extDef = extRef.FetchObjectDefinition <CdmEntityDefinition>(resOpt); if (extDef != null) { if (extDef == this) { extDef = extRef.FetchObjectDefinition <CdmEntityDefinition>(resOpt); } ResolvedEntityReferenceSet inherited = extDef.FetchResolvedEntityReferences(resOpt); if (inherited != null) { foreach (var res in inherited.Set) { ResolvedEntityReference resolvedEntityReference = res.Copy(); resolvedEntityReference.Referencing.Entity = this; entRefSetCache.Set.Add(resolvedEntityReference); } } } } if (this.Attributes != null) { for (int i = 0; i < this.Attributes.Count; i++) { // if dynamic refs come back from attributes, they don't know who we are, so they don't set the entity dynamic sub = this.Attributes.AllItems[i].FetchResolvedEntityReferences(resOpt); if (sub != null) { foreach (var res in sub.Set) { res.Referencing.Entity = this; } entRefSetCache.Add(sub); } } } ctx.UpdateCache(this, resOpt, "entRefSet", entRefSetCache); this.resolvingEntityReferences = false; } } this.Ctx.Corpus.isCurrentlyResolving = wasPreviouslyResolving; return(entRefSetCache); }