Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3114: Fix the StackOverflow exception when retrieve Partner on navigation property from big CSDL model #3121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private IEdmEntityType ComputeTargetEntityType()
return (IEdmEntityType)target;
}

private IEdmNavigationProperty ComputePartner()
internal IEdmNavigationProperty ResolveParter()
{
var partnerPropertyPath = this.navigationProperty.PartnerPath;
IEdmEntityType targetEntityType = this.TargetEntityType;
Expand All @@ -177,16 +177,54 @@ private IEdmNavigationProperty ComputePartner()
?? new UnresolvedNavigationPropertyPath(targetEntityType, partnerPropertyPath.Path, Location);
}

return null;
}

private bool partnerResolved = false;
private IEdmNavigationProperty resolvedPartner = null;
private IEdmNavigationProperty ResolvedPartner
{
get
{
if (!this.partnerResolved)
{
this.resolvedPartner = ResolveParter();
this.partnerResolved = true;
}

return this.resolvedPartner;
}
}

private IEdmNavigationProperty ComputePartner()
{
IEdmNavigationProperty navPartner = ResolvedPartner;
if (navPartner != null)
{
return navPartner;
}

IEdmEntityType targetEntityType = this.TargetEntityType;
foreach (IEdmNavigationProperty potentialPartner in targetEntityType.NavigationProperties())
{
if (potentialPartner == this)
{
continue;
}

if (potentialPartner.Partner == this)
if (potentialPartner is CsdlSemanticsNavigationProperty semanticsNav)
{
return potentialPartner;
if (semanticsNav.ResolvedPartner == this)
{
return potentialPartner;
}
}
else if (potentialPartner is EdmNavigationProperty edmNav)
{
if (edmNav.Partner == this)
{
return potentialPartner;
}
}
}

Expand Down
Loading