Iterate through linq query results from multiple tables
I have a VB .Net linq query that I want to return values from two tables. I currently h开发者_Go百科ave this:
Dim query = (From c In db.Client _
Join u In db.Users _
On u.UserID Equals c.UserID _
Where (c.ClientID = 1)
Select c, u).ToList
query (System.Collections.Generic.List(Of )) returns several rows as expected each item containing a c and a u.
How do I iterate through the queries collection? Cheers
You need to turn on Option Infer then you can iterate over it in a foreach loop. However since it's an anonymous type you can only do it in the scope of the method you're in.
精彩评论