extremely simple linq question

mpooley

Active member
Joined
Jan 4, 2009
Messages
32
Programming Experience
Beginner
Dont know why i cant work it out for myself but:rolleyes:

I am JUST looking at Linq and trying to work out what its all about so I am playing with the code - looking at examples etc .
this code should work as i see it - normally you would declare the var category but in all the examples i've seen you dont need to.
But I keep getting "category is undeclared error" on the for each loop

have i mis understood this?

Dim CategoryNames = data.BankAccounts.MainDataSet.Tables("Categorycashflow").AsEnumerable()
Dim db As New DataClasses1DataContext
Dim Categories = db.ExecuteQuery(Of CategoryCashFlowTable)( _
"SELECT [Categorycashflow].month, [Categorycashflow].Cashflow " & _
"FROM Categorycashflow AS
  • " & _
    "WHERE
    • .Year = 1993 " & _
      "ORDER BY
      • .Month;")

        For Each category In Categories
        Console.WriteLine(category)
        Next

        thanks

        Mike
 
Ok I Have used the query designer and got this working .
It seems a very longwinded way of designing a query though:confused:?

so i am hoping ill find a better way.
 
Back
Top