Skip to content

Commit

Permalink
Fix to #30115 - IndexOutOfRangeException in CreateNavigationExpansion…
Browse files Browse the repository at this point in the history
…Expression(Expression sourceExpression, IEntityType entityType) / get_Chars(Int32 index) when EF class named "<>f__AnonymousType01Child" in 7.0.2 version

Check if ShortName returns empty string, and if so use token parameter name.

Fixes #30115
  • Loading branch information
maumar committed Mar 21, 2023
1 parent 5844d95 commit d99e5c9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,12 @@ private NavigationExpansionExpression CreateNavigationExpansionExpression(
PopulateEagerLoadedNavigations(entityReference.IncludePaths);

var currentTree = new NavigationTreeExpression(entityReference);
var parameterName = GetParameterName(entityType.ShortName()[0].ToString().ToLowerInvariant());

var entityTypeName = entityType.ShortName();
var parameterName = GetParameterName(
string.IsNullOrEmpty(entityTypeName)
? "e"
: entityTypeName[0].ToString().ToLowerInvariant());

return new NavigationExpansionExpression(sourceExpression, currentTree, currentTree, parameterName);
}
Expand Down

0 comments on commit d99e5c9

Please sign in to comment.