Quick question: I'm comparing the IDs of entities in an EF4 EntityCollection against a simple int[] in a loop. I'd like to do something like:
for (int i = 0; i < Collection.Count; ++i)
{
Array.Any(a => a.value == Collection[i].ID) ? /* display yes */ : /* display no */;
}
I'm just not sure how to compare the value within the array with the value from the EntityCollection, or, in other words, what to use for real instead of the value property I made up above.
The code should be modified to read:
int[] arr = //this is the integer array
IEnumerable Collection = //This is your EF4 collection
for (int i = 0; i < Collection.Count; ++i)
{
arr.Any(a => a == Collection[i].ID) ? /* display yes */ : /* display no */;
}
I called out a few variables at the top just so we're clear as to what is what. The major part that changed was that instead of invoking Array.Any
we're invoking arr.Any
. Any
is an Extension method for int[]
and thus you invoke it on the array itself, not on the class Array
.
Does this solve the problem?