I have a LINQ query as follows:
Dim CustQuery = From a In db.Customers
Where a.GroupId = sendmessage.GroupId
Select a.CustCellphone
And would like to go through each result and get the cellphone number to do a peice of code. I have tried the following but cannot seem to get it correct:
For Each CustQuery.ToString()
...
Next
So my question then is how do I do this?
You have to set a variable in your For Each loop that will store the value of each item in your collection for you to use within your loop. The correct syntax for a VB For Each loop is:
Now if your LINQ query was a complex object, you could use the loop in the following way: