public static IEnumerable <Tuple <string, string, bool> > GetProductsByPIDs(string[] pids) { var result = new List <Tuple <string, string, bool> >(); var productTable = DALPromotion.SelectProductNamesByPIDs(pids); if (productTable != null) { foreach (DataRow item in productTable.Rows) { result.Add(Tuple.Create(item.GetValue <string>("PID"), item.GetValue <string>("DisplayName"), item.GetValue <bool>("Exist"))); } } pids?.ToList().ForEach(f => { var product = result.Where(w => w.Item1 == f).FirstOrDefault(); if (product == null) { result.Add(Tuple.Create(f, "", false)); } }); return(result); }