Reputation: 734
I have the following LINQ query in VB.NET
Using db As New ReablementLSQLDataContext
query = (From b In db.Visits
Join c In db.LinkStaffToVisits On b.ID Equals c.VisitID
Where c.StaffID = staffid And b.StartEpoch = newepochdatetime).ToList()
End Using
When I run this, it returns a list of type anonymous which means its pretty useless if I want to access any of the data in it. How do I run this join statement and return a list of a concrete type?
Upvotes: 0
Views: 856
Reputation: 20970
Anonymous types as query results aren't so "useless", since you can always foreach
over them (locally). Still, if you want a concrete type, you can add a select statement at the end and project the anonymous result into your type (supposed that you made this type and know which fields to use where), like (C# syntax)
var newQuery = query.Select(anon_x => new YourType(anon_x.field1, anon_x.field2, ...))
Upvotes: 3
Reputation: 3322
You can use a generic version of ToList
method. I am a C#
developer and can provide syntax related to C#
:
.ToList<YourType>();
For VB.Net
version read : http://msdn.microsoft.com/en-us/library/bb342261.aspx#Y0
Upvotes: 1