I'm curious as to what the "key" for a DataTable Row collection is. And if there is a better way of executing what I'm trying to do.
My situation is this. I have a DataTable populated with different data from multiple databases, for the sake of this thread let's say the different columns are: name, ID, and color. Now there are three different colors it can be: colorless, blue, and red. How the program is acting now is that if it finds one item and then finds another item that is the same beyond the color, i.e. blue pies with the ID 15 and colorless pies with the ID 15, then it makes two different rows with this information.
This is not the desired result. What I would like the program to do is look at the DataTable and see if there are any items that match in all but the color then to combine them in one of three ways. If there are two records found and one of the colors are colorless then the other color should be the one displayed with the example above that would mean there would only be a single entry for blue pies with the ID 15, the colorless pies would be ignored. If there are two records both with a color, i.e. blue pies with the ID 15 and red pies with the ID 15, then both colors should be displayed, i.e. red/blue pies with ID 15 would be displayed as one row. Finally if there are three records returned then it should be have the same way as if there were two records returned both with a color.
Now of course this problem isn't as easy as checking the data as it comes in because the method that gets all the information to add the rows to the DataTable gets it one would be row at a time.
How I was planning on executing this check was to do one of two things: A) Use the DataTable.Rows.Contains() method or B) For Each Loop through the DataTable.Rows and when it hits a row that contains the same info, minus the color, then combine it. I know in essence they are the same thing but it's the readability that is different.
So my question which is better and if I was going to go the Rows.Contains path what would the "key" value be?
Also note that this example is a super simplified version of what I'm actually doing so if you need clarification please ask.