1
Answer

EF Join to fetch data from multiple tables

Photo of Dave Bell

Dave Bell

2y
581
1

I have below entities

Student : Id, Name, .... Event : PId, SId, Name, ... , Subject[] Subject : SId, Name...

I wish to pull all Events and Subjects for given student and include Student Name only from Student

How to I join to get Student Name as well.

So far I have done

_context.event.Where(b => b.SId == request.Id).Include(c => c.Subject)

This gives me list of all Events and Subjects within each Event. How to get Student Id and Name as well...I dont mind it coming for all events.

E.g.
Id, Name, Event1 {Subjects[]},
Id, Name, Event2 {Subjects[]},

Answers (1)