Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: UpForGrabs: Consider using Contains method if available [425]

$
0
0
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.

Viewing all articles
Browse latest Browse all 10318

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>