LINQ pad在结果结束时显示SUM

时间:2015-06-17 07:55:55

标签: linq linqpad

当我通过LINQ PAD运行以下查询时,看到它在结果的末尾显示总和。这是完整的代码,它正在运行。

void Main()
{
    var csvlines = File.ReadAllLines(@"M:\smdr(backup08-06-2015).csv");
var csvLinesData = csvlines.Skip(1).Select(l => l.Split(',').ToArray());

// i am assuming that line[7] is the Party1Name Column
// now you have a (sorted) group with n "members" (ACC, Sales, ..., n )
var groupOfUser = from line in csvLinesData 
                  where  !line[12].Contains("VM") && !line[12].Contains("Voice Mail")
                  group line by line[12] into newGroup 
                  orderby newGroup.Key 
                  select newGroup;

// The Key of your userOfGrp is the Name e.g. "ACC"
// i am assuming that x[4] is the direction Column
// I count all I or O and put them into the new User
var user = (from userOfGrp in groupOfUser
            select
                new User()
                    {
                        CSRName = userOfGrp.Key,
                        Incomming = userOfGrp.Count(x => x[4] == "I"),
                        Outgoing = userOfGrp.Count(x => x[4] == "O")
                    }).ToList();
                    user.Dump();
}

class User
{
    public string CSRName;
    public int Outgoing;
    public int Incomming;
    public int calltransfer;
}

我只想知道linq pad的功能是当字段类型为数字时总是在结尾显示总和?或者在我的linq查询中有什么显示总和。

我问,因为刚开始使用linq。感谢

我的屏幕截图附件。我还在图像中放置箭头以指示我正在谈论的区域。 enter image description here

2 个答案:

答案 0 :(得分:2)

LINQad将在其结果选项卡中返回结果,任何枚举都将在其蓝色框的顶部显示如下内容:

IEnumerable<EventLogEntry> (114 items)

取决于确切的类型。最后的计数是一个LINQPad功能,当它序列化显示数据时,它不是总和。

编辑:现在我可以看到你正在谈论的结果不同的结果图片,是的,这也是一个LINQPad功能(和总和)。

答案 1 :(得分:0)

这是LINQPad的一个功能,而不是LINQ。

您可以在LINQPad中查看SQL查询的相同功能。

相关问题