Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C实体框架组计数_C#_.net_Highcharts - Fatal编程技术网

C# C实体框架组计数

C# C实体框架组计数,c#,.net,highcharts,C#,.net,Highcharts,目前正在为DotNet.Highcharts图表将数据放入某种数组中。我在从数据库中取出数据时遇到问题。实体框架给了我以下错误: DbExpressionBinding需要具有集合ResultType的输入表达式 select t.code, type, count(type) from tbl_data d join tbl_code t on d.code_name = t.code_id where type is not null group by code, type o

目前正在为DotNet.Highcharts图表将数据放入某种数组中。我在从数据库中取出数据时遇到问题。实体框架给了我以下错误:

DbExpressionBinding需要具有集合ResultType的输入表达式

 select t.code, type, count(type)
 from tbl_data d
 join tbl_code t on d.code_name = t.code_id
 where type is not null
 group by code, type 
 order by code

        using (Context db = new Context())
        {
            var data = db.tbl_data
                .Where(d => d.type != null)
                .GroupBy(d => new { d.tbl_code.code, d.type })
                .Select(d => new { name = d.Key.code, type = d.Key.type , count = d.Key.type.Count() })
                .OrderBy(d => new { d.name, d.type });

            List<string> x_Axis = new List<string>();
            List<object[]> y_Axis = new List<object[]>();

            foreach (var d in data)
            {
                x_Axis.Add(d.name);
                y_Axis.Add(new object[] { d.type, d.count });
            }

            var xArray = x_Axis.ToArray();

            render_Chart(xArray, y_Axis);
        }
编辑,因为最初的问题是琐碎的,这个新问题现在阻碍了我

code    type (No column name)
eis06   a    49
eis06   b    3
eis07   a    33
eis08   a    38
eis09   a    32
eis09   b    68
eis14   a    17
eis14   b    34
eis15   a    24
eis15   b    17
eis16   a    27
eis16   b    16