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 7948317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:41:28+00:00 2026-06-04T01:41:28+00:00

I am trying to convert following SQL query to linq; select Or.Amount, Usr.Name, Usr.Email

  • 0

I am trying to convert following SQL query to linq;

select Or.Amount, Usr.Name, Usr.Email
from [order] as Or
left join vw_AllUsers as Usr on Usr.UserId = Or.UserId and Usr.RoleName <> 'Admin'

I couldn’t find a way to use equal and not equal in the same join..
If Usr.RoleName <> ‘Admin’ was Usr.RoleName = ‘Admin’, the linq statement could be written like that

var result =  from Or in context.orders
              join Usr in context.vw_AllUsers on 
              new { userid = Or.UserId, role = "Admin"}
              equals
              new { userid = Usr.UserId, role = Usr.RoleName}
              select ........

or i can handle it in where part of the linq to get same result, as follows

where !Usr.RoleName.Equals("Admin")

but is it possible to handle this in join part of the linq ?

Thanks in advance

  • 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-04T01:41:30+00:00Added an answer on June 4, 2026 at 1:41 am

    LINQ only supports equality joins, there’s not a way to use a different operator in the join itself.

    As you point out, you can just use a where statement for the same effect. If you didn’t have an equality comparison to join on, you can use multiple from clauses.

    From MSDN:

    The equals operator


    A join clause performs an equijoin. In other words, you can only base matches on the equality of two keys. Other types of comparisons such as "greater than" or "not equals" are not supported. To make clear that all joins are equijoins, the join clause uses the equals keyword instead of the == operator. The equals keyword can only be used in a join clause and it differs from the == operator in one important way. With equals, the left key consumes the outer source sequence, and the right key consumes the inner source. The outer source is only in scope on the left side of equals and the inner source sequence is only in scope on the right side.

    Non-Equijoins


    You can perform non-equijoins, cross joins, and other custom join operations by using multiple from clauses to introduce new sequences independently into a query. For more information, see How to: Perform Custom Join Operations (C# Programming Guide).

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

Sidebar

Related Questions

I am trying to convert the following SQL into a LINQ expression SELECT COUNT(ID)
I am trying to convert the following SQL into NHibernate: SELECT * FROM dbo.Customer
I'm trying to convert the following SQL query to an ICriteria in NHibernate. SELECT
Have the following (non-straightforward) T-SQL query, which i'm trying to convert to LINQ (to
I have the following Transact-Sql that I am trying to convert to LINQ ...
I am trying to convert the following line of SQL to LINQ code :
I'm trying to convert the following statement from SQL Server to Oracle, but everything
I have the following SQL query: SELECT Comment, JD, Jurisdiction, RegStatus, Region, SPDR_NAME FROM
I have to perform the following SQL query: select answer_nbr, count(distinct user_nbr) from tpoll_answer
I'm trying to convert the following SQL to LINQ. I've had success with 1

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.