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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:49:59+00:00 2026-05-26T18:49:59+00:00

I need the equivalent of this SQL statement in Linq, using method/fluent syntax. SELECT

  • 0

I need the equivalent of this SQL statement in Linq, using method/fluent syntax.

SELECT u.[UserId], s.[UserId], d.[UserId]
FROM dbo.[Attachment] z  
INNER JOIN dbo.[Activity] a ON z.[ActivityId] = a.[ActivityId]
INNER JOIN dbo.[Case] c ON a.[CaseId] = c.[CaseId]
INNER JOIN dbo.[CaseUser] x ON c.[CaseId] = x.[CaseId]
INNER JOIN dbo.[User] u ON x.[UserId] = u.[UserId]
LEFT OUTER JOIN dbo.[User] s ON u.[SupervisorId] = s.[UserId]
LEFT OUTER JOIN dbo.[User] d ON s.[SupervisorId] = d.[UserId]
WHERE u.[UserId] = @x OR s.[UserId] = @x OR d.[UserId] = @x

Also, I use it in a context where I must return a System.Linq.Expressions.Expression object. For example, an example of existing, simpler code would be:

public override Expression<Func<Attachment, bool>> MatchingCriteria
{
  get { return a => a.Activity.Case.CaseUsers.Any(x => (x.User.Id == this.id)); }
}

I am stumped by the left joins using method syntax that evaluates to a bool.

  • 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-26T18:50:00+00:00Added an answer on May 26, 2026 at 6:50 pm

    I think the following should work… You check to make sure the related entity in the model is not null and then do a comparison if it is not:

    return a => a.Activity.Case.CaseUsers
        .Where(cu => cu.User.Id == this.id || 
               (cu.User.Supervisor != null && 
                cu.User.Supervisor.Id == this.Id) || 
               (cu.User.Supervisor != null && 
                cu.User.Supervisor.Supervisor != null && 
                cu.User.Supervisor.Supervisor.Id == this.Id));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need equivalent LINQ to SQL query for the query written in access database.
Is there a Java equivalent to PHP's mysql_real_escape_string() ? This is to escape SQL
I have this legacy database for which I'm building a custom viewer using Linq
I'm trying to figure out how to accomplish the equivalent of: select * from
I've been asked for an T-SQL challenge, I need to get the equivalent day
Linq to SQL has this very simple model: DataContext and attributes [Table] and [Column]
As the question says what is the SQL Server equivalent of INET_ATON from mySql.
I can do this in MS-Access (and it works) but need the equivalent in
i need equivalent c# code VssSdkClientId VSS_SDK_SPEC startVssSdkClientEcho(const VssSdkXChar *host, const VssSdkPort port, NotifyFunc
I need an equivalent to c++'s std::multimap<K, V, Comp, Alloc> in C-sharp. Does it

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.