I am struggling to figure out how to modify this dictionary so that it can accept two values for one key (if needed) instead of just one value. In most cases there is only one value to a key, but occasionally there are two values, and the application does not like this. Instead it throws "item with the same key already added" exception. I have been researching all over the web about dictionary as I am still learning, but have struggled and thought I might ask here for someone to point me in the right direction. From what I have read I should be using dynamic or a tuple, but I am having trouble implementing that with the code below. I know there are similar questions with answers on this site, but I am struggling to relate these answers to this code. A more specific example is greatly appreciated.
public List<ImportItem<T>> ProcessReportResult(CSVTable resultData, ICollection<ImportItem<T>> data, Func<T, string> keyFilter)
{
WriteLog("{1}{0} records found.{1}", resultData.Rows.Length, Environment.NewLine);
//key = Order Number; value = Order ID
var idDictionary = resultData.Rows.Select((row => row.Split(','))).ToDictionary(id => id[0], id => id[1]);
idDictionary.ForEach(id => WriteLog("Input Id = {0} - Matching record Id = {1}", id.Key, id.Value));
var processList = data.Where(item => idDictionary.ContainsKey(keyFilter(item.DataItem))).ToList();
processList.ForEach(item => item.Id = idDictionary[keyFilter(item.DataItem)]);
return processList;
}