We currently have code that enumerates a collection to check if it contains an element. This code could use the Contains method if it exists. Since the code deals with navigation properties it is probably also reasonable to assume that the type implements ICollection.
Code from EntityCollection CheckIfNavigationPropertyContainsEntity:
// TODO PERF: If the 'value' has a method "Contains", use it.
foreach (var o in enumerable)
{
if (Equals(o, wrapper.Entity))
{
return true;
}
}
}
Comments: I've added a [pull request](https://entityframework.codeplex.com/SourceControl/network/forks/IDisposable/WI425OptIn/contribution/5061) to allow explicitly opting into the use of Contains when a custom collection knows how to do the right thing for the classes it wraps. This allows using collections that are not HashSet-based, etc.
Code from EntityCollection CheckIfNavigationPropertyContainsEntity:
// TODO PERF: If the 'value' has a method "Contains", use it.
foreach (var o in enumerable)
{
if (Equals(o, wrapper.Entity))
{
return true;
}
}
}
Comments: I've added a [pull request](https://entityframework.codeplex.com/SourceControl/network/forks/IDisposable/WI425OptIn/contribution/5061) to allow explicitly opting into the use of Contains when a custom collection knows how to do the right thing for the classes it wraps. This allows using collections that are not HashSet-based, etc.