Entity Framework Query for inner join

c#, entity-framework

Solution

from s in db.Services
join sa in db.ServiceAssignments on s.Id equals sa.ServiceId
where sa.LocationId == 1
select s

Where `db` is your `DbContext`. Generated query will look like (sample for EF6):

SELECT [Extent1].[Id] AS [Id]
       -- other fields from Services table
FROM [dbo].[Services] AS [Extent1]
INNER JOIN [dbo].[ServiceAssignments] AS [Extent2]
    ON [Extent1].[Id] = [Extent2].[ServiceId]
WHERE [Extent2].[LocationId] = 1

Problem

What would be the query for: ``` select s.* from Service s inner join ServiceAssignment sa on sa.ServiceId = s.Id where sa.LocationId = 1 ``` in entity framework? This is what I wrote: ``` var serv = (from s in db.Services join sl in Location on s.id equals sl.id where sl.id = s.id select s).ToList(); ``` but it's wrong. Can some one guide me to the path?

Original source

Related problems