加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

linq to DataTable group by用法(VB.Net语法)

发布时间:2020-12-17 07:48:03 所属栏目:百科 来源:网络整理
导读:Module Module1 Sub Main() Dim table As New DataTable table.Columns.Add("A",GetType(Integer)) table.Columns.Add("B",GetType(Integer)) table.Columns.Add("C",GetType(Integer)) table.Columns.Add("S",GetType(Integer)) table.Columns.Add("S1",Get
Module Module1

    Sub Main()

        Dim table As New DataTable
        table.Columns.Add("A",GetType(Integer))
        table.Columns.Add("B",GetType(Integer))
        table.Columns.Add("C",GetType(Integer))
        table.Columns.Add("S",GetType(Integer))
        table.Columns.Add("S1",GetType(Integer))
        table.Columns.Add("S2",GetType(Integer))
        table.Rows.Add(1,1,1)
        table.Rows.Add(1,2,3,DBNull.Value)
        table.Rows.Add(1,4,5,DBNull.Value,1)
        table.Rows.Add(2,6,7,8,9,DBNull.Value)
        table.Rows.Add(2,11)

        Dim temp = From p In table.AsEnumerable
                                    Group p By Key = New With {Key .A = p("A"),Key .B = p("B"),Key .C = p("C")} Into g = Group
                                    Select New With {
                                        .key = Key,_
                                        .Suryo1 = g.Sum(Function(x) If(IsDBNull(x("S")),x("S")))
                                    }

        Dim a = temp.ToList()
        Dim s = ""
    End Sub

End Module

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读