Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting SQL to LINQ: The range variable conflicts with a previous declaration
    primarykey
    data
    text
    <p>I'm trying to convert this rather complex (from my perspective as I don't deal with SQL) query into LINQ:</p> <pre><code>SELECT f.description, s.description, file_no,taskid, h.description from_userid, userid, h.starttime, locktime, lockby, h.status, h.endtime FROM history h INNER JOIN flowdefinition f on h.flowid = f.flowid INNER JOIN stepdefinition s on h.flowid = s.flowid and h.stepid = s.stepid WHERE taskid = 'SERVER2012_03_08_09_31_40_367' AND h.status in ('R','U','C','K') AND h.flowid not in (999) order by endtime </code></pre> <p>And this is what I have so far:</p> <pre><code>var resultList = from h in context.History_master join f in context.flowdefinition_master on new { h.flowid, h.LocId } equals new { f.flowid, f.LocId } into hf from h in hf.DefaultIfEmpty() join s in context.stepdefinition_master on new { h.stepid, h.LocId } equals new { s.stepid, s.LocId } into hs from s in hs.DefaultIfEmpty() where h.file_no == fileNumber orderby h.endtime select new { }; </code></pre> <p>But this complains that "The range variable 'h' conflicts with a previous declaration of 'h'. I understand that it says it is like a second declaration, but I don't know how else i would do this in LINQ. Any help with this (complete or partial :) ) would be greatly appreciated!</p> <p>//EDIT:</p> <p>If i change the <code>from h in hf.DefaultIfEmpty()</code> to <code>from h1 in hf.DefaultIfEmpty()</code> as suggested, the h1 does not have the same properties as h. So i can't do the second join because the tables are not there...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload