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

Removing defensive copies #24814

Merged
Merged
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 @@ -234,31 +234,24 @@ public static bool IsConcurrencyTokenMissing(

private static void RemoveDerivedEntityTypes<T>(Dictionary<IConventionEntityType, T> entityTypeDictionary)
{
var toRemove = new HashSet<KeyValuePair<IConventionEntityType, T>>();
var entityTypesWithDerivedTypes =
entityTypeDictionary.Where(e => e.Key.GetDirectlyDerivedTypes().Any()).ToList();
entityTypeDictionary.Where(e => e.Key.GetDirectlyDerivedTypes().Any());
foreach (var entityType in entityTypeDictionary.Where(e => e.Key.BaseType != null))
{
foreach (var otherEntityType in entityTypesWithDerivedTypes)
{
if (toRemove.Contains(otherEntityType)
|| otherEntityType.Equals(entityType))
if (otherEntityType.Equals(entityType))
{
continue;
}

if (otherEntityType.Key.IsAssignableFrom(entityType.Key))
{
toRemove.Add(entityType);
entityTypeDictionary.Remove(entityType.Key);
break;
}
}
}

foreach (var entityType in toRemove)
{
entityTypeDictionary.Remove(entityType.Key);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ private NavigationExpansionExpression ProcessCastOfType(
var siblingNavigations = newEntityReference.IncludePaths.Keys
.Where(
n => !castEntityType.IsAssignableFrom(n.DeclaringEntityType)
&& !n.DeclaringEntityType.IsAssignableFrom(castEntityType)).ToList();
&& !n.DeclaringEntityType.IsAssignableFrom(castEntityType));

foreach (var navigation in siblingNavigations)
{
Expand Down