lambda表达式常用

47 阅读1分钟
  • 单一分组
Dim groups = dt.Rows.OfType(Of DataRow).GroupBy(Function(p) p.Field(Of Integer)("RENRAKU_NO"))
  • 多字段分组
'Dim groups = dt.Rows.OfType(Of DataRow).GroupBy(Function(p) p.Field(Of String)("KOUBAN_NO"))
Dim groups = dt.Rows.OfType(Of DataRow).GroupBy(Function(p) (KOUTEI_IRAI_CODE:=p.Field(Of String)("KOUBAN_NO").ToString(), ANOTHER_FIELD:=p.Field(Of Integer)("KOUBAN_EDA_NO")))

  • 分组的某一字段求和
    '仕入先計 現在のグループの仕入金額の合計
    data(rowIdx, colIdx) = group.Sum(Function(row) row.Field(Of Integer)("SHIIRE_KIN"))