Entity Framework Joins

In a previous post we saw that it is recommended to use navigation properties in Linq to SQL. But, what if you don’t have navigation properties and still want to join two tables? The answer is in the question: use the join operator. Below is the query that I built. Note that I want to return a custom selection. That’s why I used a custom component named ProcessTrigger. Query:

ProcessStepTrigger trigger;

trigger = (from PF in contextCommon.ProcessFlows
join PS in contextCommon.ProcessSteps
on PF.StepId equals PS.StepId
where PF.Status == “Processing” && PS.Name == “SendServiceOrderToNavision”
orderby PF.SequenceId ascending
select new ProcessStepTrigger { ProcessFlowId = PF.SequenceId, EntityId = PF.EntityId }).FirstOrDefault();

After I build the solution I got the following error:
Could not find an implementation of the query pattern for source type ‘DbSet<ProcessFlow>’.  ‘Join’ not found.

Reason for this is that I didn’t add a using statement for System.Linq. After I added the using statement, the query worked.

Leave a Reply

Your email address will not be published. Required fields are marked *