2

我正在尝试将以下 LINQ 查询结果转换为字典

var browser = (from tbf in context.tblFeedBacks
                        where tbf.email == dboard.userEmail
                        select tbf).GroupBy(l => l.browser)
                        .Select(g => new
                        {
                            browser = g.Key,
                            count = g.Select(l => l.browser).Distinct().Count()
                        });

它给了我一个编译错误。

var browser = (from tbf in context.tblFeedBacks
                            where tbf.email == dboard.userEmail
                            select tbf).GroupBy(l => l.browser)
                            .Select(g => new
                            {
                                browser = g.Key,
                                count = g.Select(l => l.browser).Distinct().Count()
                            }).ToDictionary<string, double>(x => x.browser,y=>y.count);

实例参数:无法从“System.Linq.IQueryable”转换为“System.Linq.ParallelQuery”

4

1 回答 1

4

让它工作。

var browser = (from tbf in context.tblFeedBacks
                            where tbf.email == dboard.userEmail
                            select tbf).GroupBy(l => l.browser)
                            .Select(g => new
                            {
                                browser = g.Key,
                                count = g.Select(l => l.browser).Count()
                            }).ToDictionary(x => x.browser, x => x.count);
于 2013-10-22T03:17:40.490 回答