LINQ,加入,分组依据和总和 [英] LINQ, Join, Group By and SUM
本文介绍了LINQ,加入,分组依据和总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此VB.NET查询中,如何获得对新语句中字段的访问?
In this VB.NET query, how can I get access to the fields in the new statement?
Dim query =
From t1 In tbl1
Join t2 In tbl2 On t1.CAMPAIGNID Equals t2.CAMPAIGNID
Group By t1.CAMPAIGNID Into Group
Select New With {
.id = CAMPAIGNID,
.CALLS = Group.Sum(Function(a) t2.CALLS),
.count = Group.Count(Function(a) t1.TERMCD = "Refused")
}
推荐答案
您可以通过传入的参数a
访问这些字段.参数a
是您通过New With {...}
You can access the fields via the passed in parameter a
. The parameter a
is of the anonymous type you created via New With {...}
Dim query =
From t1 In tbl1
Join t2 In tbl2 On t1.CAMPAIGNID Equals t2.CAMPAIGNID
Group By t1.CAMPAIGNID Into Group
Select New With {
.id = CAMPAIGNID,
.CALLS = Group.Sum(Function(a) a.t2.CALLS),
.count = Group.Count(Function(a) a.t1.TERMCD = "Refused")
}
这篇关于LINQ,加入,分组依据和总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文