c# group by list

 ViewBag.PnlTotal = pnlTotal;
            // 柱形图
            string data = "";
            string cat = "";
            string buyOrderTotalOrderAmount = "";

            var r = listReports.OrderBy(p => p.DateRange).ThenBy(p => p.VendorID).GroupBy(g => g.DateRange).Select(g =>
              new PnlDiagram
              {
                  Key = g.Key,
                  Value = string.Join(",", g.Select(c => c.VendorTotalPnL)),
                  BuyOrderTotalOrderAmount=string.Join(",",g.Select(p=>p.BuyOrderTotalOrderAmount)),
                  Partner = string.Join(",", g.Select(c => c.VendorID))
              });

            foreach (var item in r)
            {
                cat = item.Partner;
                data += "name:" + item.Key + "#data:[" + item.Value + "];";
                buyOrderTotalOrderAmount += "name:" + item.Key + "#data:[" + item.BuyOrderTotalOrderAmount + "];";
            }
            ViewBag.CatNew = cat;
            ViewBag.DataNew = data;
            ViewBag.BuyOrderTotalOrderAmount = buyOrderTotalOrderAmount;
            return PartialView("PNLReport_Partial", listReports);

结果

@{
ViewBag.Title = "PNLReport_Diagram";
Layout = null;
var CatNew = Html.Raw(ViewBag.CatNew);
var DataNew= Html.Raw(ViewBag.DataNew);
}

时间: 2024-11-07 23:20:14

c# group by list的相关文章

djfhkjdahsg 将会对会计师公会斯蒂芬

http://f.dangdang.com/group/24690/7818358/ http://f.dangdang.com/group/24690/7818366/ http://f.dangdang.com/group/24690/7818410/ http://f.dangdang.com/group/24690/7818420/ http://f.dangdang.com/group/24690/7818408/ http://f.dangdang.com/group/24690/7

供应科顾客顾客顾客

http://f.dangdang.com/group/24554/3373214/http://f.dangdang.com/group/24554/3373218/http://f.dangdang.com/group/24554/3373222/http://f.dangdang.com/group/24554/3373227/http://f.dangdang.com/group/24554/3373230/http://f.dangdang.com/group/24554/337323

放假放假放假凤凰男

http://f.dangdang.com/group/24554/3373214/http://f.dangdang.com/group/24554/3373218/http://f.dangdang.com/group/24554/3373222/http://f.dangdang.com/group/24554/3373227/http://f.dangdang.com/group/24554/3373230/http://f.dangdang.com/group/24554/337323

passwd、shadow、group结构及各字段含义

/etc/password结构 sample:root:x:0:0:root:/root:/bin/bash 账号名称 密码 UID GID 用户信息说明 家目录 Shell root x 0 0 root /root /bin/bash /etc/shadow结构: sample:root:$1$/30QpE5e$y9N/D0bh6rAACBEz.hqo00:14126:0:99999:7::: 账号名称 密码 最近更动密码的日期 密码不可被更动的天(0代表随时可以变动) 密码需要重新变更的天

SQL Server Pivot 隐藏group

SQL Server行列转换隐藏group Pivot有一个隐藏的Group 分组, 除了Pivot column 和value列,其他列作为分组 Example: IF NOT EXISTS(SELECT * FROM sys.tables where name = 'Pivot_test') CREATE TABLE Pivot_test ( id1 int, id2 int, Pivot_column varchar(50), value char(50) ) insert into Pi

SQL group 分组查询

1.使用group by进行分组查询  在使用group by关键字时,在select列表中可以指定的项目是有限制的,select语句中仅许以下几项:  被分组的列 为每个分组返回一个值得表达式,例如用一个列名作为参数的聚合函数group by的使用在这只写几个例子吧:例: select courseID,avg(score) as 课程平均成绩 from score group by courseID 例: select studentID as 学员编号,courseID as 内部测试,a

【LeetCode】49. Group Anagrams

Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: [ ["ate", "eat","tea"], ["nat",

32.GROUP BY

合计函数 (比如 SUM) 常常需要添加 GROUP BY 语句. GROUP BY 语句 GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 语法 SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name SQL GROUP BY 实例 我们拥有下面这个 "Or

mySQL之group By的简单分析

1.测试数据: create table `t_class` ( `id` bigint (11), `name` varchar (150), `age` int (11), `class` int (11) );  insert into `t_class` (`id`, `name`, `age`, `class`) values('1','tom1','22','1'); insert into `t_class` (`id`, `name`, `age`, `class`) value

sql篇 select from where group by having order by

以前,自己总是记不住如何用group by,如何用order by,什么时候用group by,什么时候用order by,什么时候两者一起用,怎么用,谁先谁后,现在,我们就一起来说一下Select   from   where   groupby   having   order by 的那些事,简单的总结一下,加深一下自己的印象,也给有需要的人提供点资源 Select   from   where   groupby   having   order by ,不用说,select from肯