Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8356401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:11:15+00:00 2026-06-09T10:11:15+00:00

I’m trying to convert this rather complex (from my perspective as I don’t deal

  • 0

I’m trying to convert this rather complex (from my perspective as I don’t deal with SQL) query into LINQ:

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

And this is what I have so far:

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
                 {

                 };

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!

//EDIT:

If i change the
from h in hf.DefaultIfEmpty() to from h1 in hf.DefaultIfEmpty() 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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:11:17+00:00Added an answer on June 9, 2026 at 10:11 am

    I figured it out. Like other answers said, i had a double declaration, but also the join was not correct. The correct way is like this: (as a Lambda Expression)

     IList<HistoryView> resultList2 = context.History_master.Join(context.flowdefinition_master, h=> new {h.flowid, h.LocId}, f=>new{f.flowid, f.LocId}, (h,f) => new {h,f})
                                                                .Join(context.stepdefinition_master, h=> new {h.h.flowid, h.h.LocId}, s=>new{s.flowid, s.LocId}, (h,s) => new {h,s})
                                                                .Where(x=>x.h.h.file_no == fileNumber)
                                                                .Where(x => (x.h.h.status == "R") || (x.h.h.status == "U") || (x.h.h.status == "C") || (x.h.h.status == "K"))
                                                                .Select(r=> new HistoryView { 
                                                                    flowDescription = r.h.f.description,
                                                                    stepDescription = r.s.description, 
                                                                    fileNumber = r.h.h.file_no,
                                                                    taskId = r.h.h.taskid,
                                                                    fromUser = r.h.h.from_userid,
                                                                    userId = r.h.h.userid,
                                                                    startTime = r.h.h.starttime,
                                                                    lockTime = r.h.h.locktime,
                                                                    lockBy = r.h.h.lockby,
                                                                    status = r.h.h.status,
                                                                    endTime = r.h.h.endtime
                                                                }).ToList();
    

    Thanks for all the suggestions 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I'm trying to select an H1 element which is the second-child in its group
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.