您的位置:首页 > 其它

System.NotSupportedException: LINQ to Entities 不识别方法“System.Decimal ToDecimal(Int32)”,因此该方法无法转换为存储表达

2017-03-01 09:57 555 查看
 var sectionBasin = (from s in section

                                    join b in standard

                            on s.SectionCode equals b.SectionCode

                                    select new

                                    {

                                        SectionCode = s.SectionCode,

                                        Province = s.Province,

                                        Standard = b.Standard

                                    }) .GroupBy(x => x.Province).Select(t => new

                                    {

                                        code = t.Key,

                                        upStd = t.Where(x => x.Standard == 0).Count(),

                                        subStd = t.Where(x => x.Standard == 1).Count(),

                                        upsub=t.Count(),

                                        rate = Convert.ToDecimal(t.Where(x => x.Standard == 0).Count()) / Convert.ToDecimal(t.Count())
                                    });

报错:

System.NotSupportedException: LINQ to Entities 不识别方法“System.Decimal ToDecimal(Int32)”,因此该方法无法转换为存储表达

改成先List,再GroupBy

 }).ToList() .GroupBy(x => x.Province).Select(t => new
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐