entity-frameworklinqlambdaado.net-entity-data-model

Entity Framework - query all records across linking tables


I'm getting lost down the rabbit-hole of EF and Lambdas. I'm trying to get all records from across linking tables.

I'm pretty sure my question is answered here but I can't work out how to apply the answer to my situation.

Here's a simplified model layout of my db.

Simplified DB Model

I'm trying to get a list of all the Speakers for a given event but can't work out how to build the Linq / Lambdas.

To be clear:

Any help?


Solution

  • Typically after staring at the problem for over an hour and then posting here I think I've worked it out.

    context.SessionSpeakers.Where(x => x.Session.EventId == odv.EventId).Select(x => x.Speaker);
    

    I'll leave this here in case this helps someone else or anyone wants to offer a better answer.