0

以下の指定されたクエリは、コンパイル時にエラーを示しています。The name wfmilestoneprojectrelis not in scope の右側に表示されequalsます。の両側の式を交換することを検討してくださいequals。どうすればこれを解決できますか?
助けてください...

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

4

1 に答える 1

1

舞台裏で呼び出される Join メソッドの定義を見てください。

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

デリゲートに変数 workflowmilestone (TInner) が渡されたため、2 番目の結合句で変数 wfmilestoneprojectrel が使用できないため、このエラーが発生する理由は次のとおりです。

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

単に書いてみませんか:

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

たぶん私は何かを誤解しています..

于 2013-07-06T09:30:50.953 に答える