0

Specified query below shows error in compile time. it says The name wfmilestoneprojectrel is not in scope on the right side of equals. Consider swapping the expressions on either side of equals. How can i resolve this ?
please help...

var test = (from wfmilestonedefinition in _context.WF_MILESTONE_DEFINITION join wfmilestoneprojectrel in _context.WF_MILESTONE_PROJECT_REL on wfmilestonedefinition.MILESTONE_ID equals wfmilestoneprojectrel.MILESTONE_ID join workflowrecord in _context.WORKFLOW_RECORD on wfmilestoneprojectrel.PROJECT_ID equals workflowrecord.PROJECT_ID join workflowmilestone in _context.WORKFLOW_MILESTONE on new { wfmilestoneprojectrel.MILESTONE_PROJECT_REL_ID, workflowrecord.WF_ID } equals new { MILESTONE_PROJECT_REL_ID = wfmilestoneprojectrel.MILESTONE_PROJECT_REL_ID, workflowmilestone.WF_ID } select workflowmilestone).ToList(); 

Related Sql query which works well are given below : SELECT dbo.WF_MILESTONE_DEFINITION.MILESTONE_ID, dbo.WF_MILESTONE_DEFINITION.MILESTONE_NAME, dbo.WF_MILESTONE_PROJECT_REL.PROJECT_ID, dbo.WORKFLOW_RECORD.WF_ID, dbo.WORKFLOW_MILESTONE.MILESTONE_E_DATE FROM dbo.WF_MILESTONE_DEFINITION INNER JOIN dbo.WF_MILESTONE_PROJECT_REL ON dbo.WF_MILESTONE_DEFINITION.MILESTONE_ID = dbo.WF_MILESTONE_PROJECT_REL.MILESTONE_ID INNER JOIN dbo.WORKFLOW_RECORD ON dbo.WF_MILESTONE_PROJECT_REL.PROJECT_ID = dbo.WORKFLOW_RECORD.PROJECT_ID INNER JOIN dbo.WORKFLOW_MILESTONE ON dbo.WF_MILESTONE_PROJECT_REL.MILESTONE_PROJECT_REL_ID = dbo.WF_MILESTONE_PROJECT_REL.MILESTONE_PROJECT_REL_ID AND dbo.WORKFLOW_RECORD.WF_ID = dbo.WORKFLOW_MILESTONE.WF_ID

2
  • Which part of this Consider swapping the expressions on either side of 'equals' you don't understand? Did you try it? Commented Jul 6, 2013 at 9:04
  • yes i try it.. but don't work. I translated this query from sql. sql query works as well. Commented Jul 6, 2013 at 9:17

1 Answer 1

1

Look at definition of Join method that will be called behind the scenes:

Join<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter, TKey>>, Expression<Func<TInner, TKey>>, Expression<Func<TOuter, TInner, TResult>>) 

The reason why are you getting this error because in your second join clause variable wfmilestoneprojectrel is not available because to that delegate passed variable workflowmilestone (TInner):

 new { //here is no varialbe with name wfmilestoneprojectrel MILESTONE_PROJECT_REL_ID = wfmilestoneprojectrel.MILESTONE_PROJECT_REL_ID, workflowmilestone.WF_ID } 

Why not just write:

join workflowmilestone in _context.WORKFLOW_MILESTONE on workflowrecord.WF_ID equals workflowmilestone.WF_ID 

Maybe I'm misunderstanding something..

Sign up to request clarification or add additional context in comments.

2 Comments

And given that the OP is using wfmilestoneprojectrel.MILESTONE_PROJECT_REL_ID in both of the anonymous objects it looks to me like it could just be removed...
Thanks @Alexey for your feedback but i need wfmilestoneprojectrel.MILESTONE_PROJECT_REL_ID in both site of on query because it filters some data as my desired output.please help if i want my way then how can i do this ? just look the sql query ten you can understand.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.