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

  • Home
  • SEARCH
  • 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 6078579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:50:59+00:00 2026-05-23T10:50:59+00:00

I have a SQL statement which I am trying to convert into LINQ to

  • 0

I have a SQL statement which I am trying to convert into LINQ to SQL, and I’ve managed to get most of it converted, but have come across one statement which I can’t wrap my head around in LINQ.

The section of the SQL query that’s causing the headache is:

SELECT *
FROM step
INNER JOIN action on 
    (step.NextAction = action.ID and step.ActionStatus != 4) or 
    (step.ACTION = action.ID and step.ActionStatus = 4)

step is a table containing a sequence of actions, action is the list of actions available. ActionStatus is an index into a list of statuses – 4 == ‘Failed’.

Basically, for actions which are not Failed, it needs to return the next action. If the action has Failed, it returns the current action.

This is just one of the joins (there are a total of 10 tables in the full query), most of them are straight forward equijoins, some on multiple conditions, but I’ve been able to write them in LINQ with no issue. This one though, I can’t see how it would be written.

I saw this answer, but also can’t see how to apply that in this scenario. Any ideas?

  • 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-05-23T10:51:00+00:00Added an answer on May 23, 2026 at 10:51 am
    from s in step
    from a in action
    where (s.NextAction = a.ID && s.ActionStatus != 4) || (s.Action = a.ID && s.ActionStatus = 4)
    select new { Step = s, Action = a };
    

    You might want to look at the SQL generated and optimise if needed.

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

Sidebar

Related Questions

I'm have a SQL statement which I am trying to transform in a LINQ
I'm trying to convert the following to a LINQ to SQL statement in C#.
I have a SQL statement which returns a number of rows and these are
I have the following SQL statement which has a very bad performance: SELECT frmInstLastModifiedDate
I have a fairly large SQL statement which has a number of inner joins
I have a method which includes sql statement . it is public Boolean addRSS(string
I have 3 tables which need to be linked in an SQL statement (I'm
I currently have this statement in my SQL View (SQL Server 2008 R2) which
I have a sql statement that concatenates two columns, ItemNumber and Name, into one
I am trying to form a sql statement which checks for duplicated userids WITHIN

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.