ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码

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

来源:网络整理     时间:2015-02-19     关键词:

本篇文章主要介绍了"linq to DataTable group by用法(VB.Net语法)",主要涉及到方面的内容,对于VBjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下: Module Module1Sub Main()Dim table As New DataTabletable.Columns.Add("A", GetType...

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, 1, 1, 1)
        table.Rows.Add(1, 1, 1, 2, 1, 1)
        table.Rows.Add(1, 1, 2, 3, 2, DBNull.Value)
        table.Rows.Add(1, 1, 2, 4, 2, 1)
        table.Rows.Add(1, 1, 3, 5, DBNull.Value, 1)
        table.Rows.Add(2, 1, 3, 6, 3, 1)
        table.Rows.Add(2, 1, 3, 7, 3, 1)
        table.Rows.Add(2, 1, 4, 8, 4, 1)
        table.Rows.Add(2, 1, 4, 9, 4, 1)
        table.Rows.Add(2, DBNull.Value, 4, DBNull.Value)
        table.Rows.Add(2, DBNull.Value, 4, 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")), 0, x("S")))
                                    }

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

End Module

以上就介绍了linq to DataTable group by用法(VB.Net语法),包括了方面的内容,希望对VBjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_113923.html

相关图片

相关文章