在方法中使用var变量" AsEnumerable"投掷错误

时间:2017-06-12 09:16:58

标签: c# visual-studio linq visual-studio-2012

大家好,我运行代码时遇到错误,错误是

"指定的演员表无效。"

这是我的代码

       var result = dst.Tables["SalesInAccpac"].AsEnumerable()
                         .GroupBy(row => new
                         {
                             Mon = row.Field<int>("Mon"),
                             Region = row.Field<string>("Region"),
                             Str = row.Field<string>("Str"),
                             RcptDate = row.Field<DateTime>("RcptDate")
                         }).Select(x => new
                                  {
                                      Mon = x.Key.Mon,
                                      Region = x.Key.Region,
                                      Str = x.Key.Str,
                                      RcptDate = x.Key.RcptDate,
                                      TotalCost = x.Sum(z => z.Field<double>("TotalCost")),
                                      TotalRound = x.Sum(z => z.Field<double>("TotalRound"))
                                  });



        foreach (var item in result)
        {
            string sos = item.Mon.ToString();
            string TotalCost = item.TotalCost.ToString();
        }

请任何人帮助我吗?

0 个答案:

没有答案