GroupBy using System.Linq.Dynamic RRS feed

  • Question

  • I want to group some rows in da dataset using the System.Linq.Dynamic library but I always get an array of all datarows as result of the query. What am I doing wrong? Here is an example fom the code i want to use:

            Dim ds As New DataSet
            ds.Tables("DataTable1").Columns.Add("DataColumn1", GetType(String), "")

            Dim row As DataRow = ds.Tables("DataTable1").NewRow
            row.Item("DataColumn1") = "Test"
            Dim row2 As DataRow = ds.Tables("DataTable1").NewRow
            row2.Item("DataColumn1") = "Test"
            Dim row3 As DataRow = ds.Tables("DataTable1").NewRow
            row3.Item("DataColumn1") = "Test2"
            Dim row4 As DataRow = ds.Tables("DataTable1").NewRow
            row4.Item("DataColumn1") = "Test2"

            Dim test = _
                From dt In ds.Tables("DataTable1").AsEnumerable.AsQueryable _
                .GroupBy("@0", "it", "dt.Field(Of String)(""DataColumn1"")")

    The test query always returns an array of all rows insted of grouped rows. Is it possible to group the rows into group objects with the dynamic library as it is possible with the static linq groupby command? (Group By
    DataColumn1 Into g = Group)
    Friday, September 5, 2008 8:45 AM