Hello;
I have a sample dictionary as follows:
Dictionary<strign, List<string>> recon= new Dictionary<strign, List<string>>();
List<string> referenceId= new List<string>();
referenceId.Add("0001");
referenceId.Add("0002");
referenceId.Add("0003");
referenceId.Add("0004");
List<string> productCode= new List<string>();
productCode.Add("abc");
productCode.Add("def");
productCode.Add("ght");
productCode.Add("yuk");
recon["referenceId"] = referenceId;
recon["productCode"] = productCode;I am trying to iterate over only referenceId values and get the values. How can I achieve it? By the way is there any shortcut version rather than using 2 for each loops?
var reconResult = await (context.GameBanks.Where(g => g.used == 0)
.Where(l => l.referenceId != null)
).ToListAsync();
if (reconResult.Count() != 0)
{
foreach (var item in reconResult)
{
foreach (KeyValuePair<string, List<string>> entry in recon.Where(r => r.Key == "referenceId"))
{
if (item.referenceId == entry.Value[0])
{
//item.used = 1;
}
}
}
}Best Regards.