>> >> Dim osql As New sqlClass : osql.Execute("qryBestelKK") >> Dim orders As IEnumerable(Of DataRow) = osql.dt.AsEnumerable >> >> Dim test = From r In orders _ >> Group r By name = r.Field(Of String)("KL_Naam") _ >> Into g = Group Select New With {.Name = name, .total = g.Sum(Function(r) r.Field(Of Decimal)("Bestd_Waarde"))} >> >> For Each r In test >> Console.WriteLine("name: {0} total {1}", r.Name, r.total) >> Next >> >>>>
>>' Fill the DataSet. >>Dim ds As New DataSet() >>ds.Locale = CultureInfo.InvariantCulture >>' See the FillDataSet method in the Loading Data Into a DataSet topic. >>FillDataSet(ds) >> >>Dim products As IEnumerable(Of DataRow) = _ >> ds.Tables("Product").AsEnumerable() >> >>Dim query = _ >> From product In products _ >> Group product By style = product.Field(Of String)("Style") Into g = Group _ >> Select New With _ >> { _ >> .Style = style, _ >> .AverageListPrice = g.Average(Function(product) _ >> product.Field(Of Decimal)("ListPrice")) _ >> } >> >>For Each product In query >> Console.WriteLine("Product style: {0} Average list price: {1}", _ >> product.Style, product.AverageListPrice) >>Next >>>>