I have 3 tables in a database:
image of the database
I have been looking online for a long time tr开发者_C百科ying to find out how in linq and vb.net how i can do a query that has access to both the event and individual table for example showing all the events individual 1 is taking part in ect. i was wondering if anyone could point me in the right direction or know of any good tutorial sites with good examples of things similar.
Thanks in advance :) Luke.
'Start' your query from the IndividualTakingPart
table.
Dim Events = From itp in context.IndividualTakingPart _
Where itp.Individual_id = 1 _
Select itp.Events
Update (in response to comments below)
You need to have a primary key on the joining table to enable the associations to the other tables.
Sounds like you needs something like this.
Public Function GetEventsByIndividual(ByVal individual As Individual) As IEnumerable(Of Event)
Return individual.IndividualTakingParts _
.SelectMany(Function(itp) itp.Events)
End Function
精彩评论