C#里怎么用linq代替foreach?类似下面的情形!求助各位大佬

DataTable dtData = qhDataSet.dtCj.DefaultView.ToTable();
                    for (int i = 0; i < dtData.Rows.Count; i++)
                    {
                        string keyString = string.Format("{0}@{1}@{2}@{3}@{4}@{5}@{6}",
                                      dtData.Rows[i]["proflname_"], dtData.Rows[i]["mkcode_"], dtData.Rows[i]["stkcode_"], dtData.Rows[i]["stkname_"], dtData.Rows[i]["kptp_"], dtData.Rows[i]["bstp_"], dtData.Rows[i]["shtp_"]);

                        List<DataRow> valueList = null;
                        if (keyIndex.TryGetValue(keyString,out valueList))
                        {
                            valueList.Add(dtData.Rows[i]);
                        }
                        else
                        {
                            keyIndex.Add(keyString, new List<DataRow>() { dtData.Rows[i] });
                        }
                    }

 

 记得采纳(^U^)ノ~YO

 var keyIndex = dtData.AsEnumerable()
                //分组
                .GroupBy(i => string.Format("{0}@{1}@{2}@{3}@{4}@{5}@{6}", i.Field<string>("proflname_"), i.Field<string>("mkcode_"), i.Field<string>("stkcode_"), i.Field<string>("stkname_"), i.Field<string>("kptp_"), i.Field<string>("bstp_"), i.Field<string>("shtp_")))
                //转字典
                .ToDictionary(g => g.Key, g => g.ToList());