In the code below I am populating a Jagged array full of keys(properties) in an object:
foreach (var item in Items.Where(x => x.NeedsSaved))
{
int[][] valuePairs = new int[item.Collection.Count()][];
int i = 0;
foreach (var collectionItem in item.Collection)
{
valuePairs[i] = new int[4] { collectionItem.Id1, collectionItem.Id2, collectionItem.Id3, collectionItem.Id4};
i++;
}
-- TODO
}
return false;
I am trying to determine if any duplicate key pairs exist. I'm sure there is something easy I am missing with Linq. Every pair of 4 values needs to be unique, so If I have a collection of two in the array that are equal to :
{1, 1, 1, 1}
and
{1, 1, 1, 1}
The method should return true.
but if the values are
{1, 1, 1, 1}
{2, 1, 1, 1}
The method should return false.
To add further clarification, the purpose is that when saving in a Client, I am posting to the API. This object has a compound primary key of (a, b, c, d) so I am trying to warn the user by validation before the API is hit, causing a duplicate key exception.
I appreciate any help, and if this is a duplicate I apologize, I tried searching as best as I could for an answer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…