Hallo zusammen,
ich habe folgende Linq Abfrage erstellt
Dim qryoGR = From dt In remGR.AsEnumerable _
Group By g = dt.Field(Of String)("Kostenart") Into mygroup _
= Group
Select New With {.Plan_Jan = mygroup.Sum(Function(item) _
item.Field(Of Double?)("Plankosten_01")), _
.Plan_Feb = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_02")), _
.Plan_Mrz = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_03")), _
.Plan_Apr = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_04")), _
.Plan_Mai = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_05")), _
.Plan_Jun = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_06")), _
.Plan_Jul = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_07")), _
.Plan_Aug = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_08")), _
.Plan_Sep = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_09")), _
.Plan_Okt = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_10")), _
.Plan_Nov = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_11")), _
.Plan_Dez = mygroup.Sum(Function(item) item.Field( _
Of Double?)("Plankosten_12")), _
.Ist_Jan = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_01")), _
.Ist_Feb = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_02")), _
.Ist_Mrz = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_03")), _
.Ist_Apr = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_04")), _
.Ist_Mai = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_05")), _
.Ist_Jun = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_06")), _
.Ist_Jul = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_07")), _
.Ist_Aug = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_08")), _
.Ist_Sep = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_09")), _
.Ist_Okt = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_10")), _
.Ist_Nov = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_11")), _
.Ist_Dez = mygroup.Sum(Function(item) item.Field(Of _
Double?)("Istkosten_12"))} Nun möchte ich über eine Schleife verschiedene Werte addieren
z.B.
For Each row In qryoGR
Dim sumPlan As Double = 0
For m As Integer = 1 To month
sumPlan = sumPlan + "row.Plan_" & MonthName(m, True)
Next
Next Natürlich funktioniert "row.Plan_" & MonthName(m, True) so nicht.
Wie kann ich das entsprechende Item in dieser Schleife ansprechen?
Vielen Dank im Voraus!
Grüße Josch
Beitrag wurde zuletzt am 04.11.15 um 10:21:08 editiert. |