8,497
社区成员
发帖
与我相关
我的任务
分享
Public Sub Linq41()
Dim words = New String() {"blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese"}
Dim wordGroups = From w In words _
Group w By Key = w(0) Into Group _
Select FirstLetter = Key, WordGroup = Group
For Each g In wordGroups
Console.WriteLine("Words that start with the letter '{0}':", g.FirstLetter)
For Each w In g.WordGroup
Console.WriteLine(w)
Next
Next
End Sub
var Total=from R in Dt
group R by R.Stat into G
select new {QtySaleTotal = G.Sum(x => x.QtySale), AmtSaleTotal = G.Sum(x => x.AmtSale), QtyBackTotal = G.Sum(x => x.QtyBack), AmtBackTotal = G.Sum(x => x.AmtBack), ProFit = G.Sum(x => x.Profit)};
Dim total = (From R In DtSet.Table("Sale_d").AsEnumerable() _
Group R By R..Field(Of Integer)("Customer_Id") Into G).
Select(Function(x)
Dim a = (From x In G Select x.Qty_Sale).Sum()
Dim b = (From x In G Select x.Amt_Sale).Sum()
Return New With _
{
.key = G.Key, _
.A = a, _
.B = b
}
Dim total = From R In DtSet.Table("Sale_d").AsEnumerable() _
Group R By R..Field(Of Integer)("Customer_Id") Into G _
Select New With _
{
key=G.Key, _
.A =(From x In G Select x.Qty_Sale).Sum(), _
.B = (From x In G Select x.Amt_Sale).Sum()
}