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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:12:05+00:00 2026-06-17T23:12:05+00:00

Bit of Linq method syntax from a newbie here, so I appreciate any insights

  • 0

Bit of Linq method syntax from a newbie here, so I appreciate any insights anyone can pass along. What I need seems simple, but it’s running me around in circles. I have 2 tables and an association (basically a junction table with only 2 fields). I’ve gone through numerous posts on SO, but I’m just not getting it. Frustrating. Ok, using EF4, I have Reports and Roles and a navigation property on Reports called Roles which is the junction table (with ReportId and RoleId fields, both integer fields). I use a UserId to get all associated roles from the Roles table, use those roles to get the associated reports from the junction table and then get the names of the reports from Reports.

I’ve tried LinqPad, but what it produces in lambda method syntax won’t even work when I paste it back into LinqPad.

SQL query:

select Reports.ReportName 
 from Reports 
 inner join UserRoles on Reports.ReportId = UserRoles.ReportId 
 inner join Roles on Roles.RoleId = UserRoles.RoleId 
 where UserRoles.UserId == userId

Code so far:

Reports.Select(a => a.Roles.Where(t => t.UserRoles.Select(u => u.UserId == userId)));
  • 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-17T23:12:06+00:00Added an answer on June 17, 2026 at 11:12 pm

    You can give this a shot, you may also want to filter down your select based on your needs:

    var result = from allReports in Reports
                 join userRoles in userRoles on allReports.ReportId equals userRoles.ReportId
                 join roles in Roles on userRoles.RoleId equals roles.RoleId
                 where userRoles.UserId == userid
                 select allReports; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anyone help me write a linq query, its a bit confusing... Basically i
I've recently started using LINQ quite a bit, and I haven't really seen any
I'm having some issues with a bit of LINQ syntax and I believe I'm
I need to transform some paginated data from Linq to Entity Framework. The data
As far as I can understand, the linq method FirstOrDefault() returns null if a
I'm writing a bit of LINQ to SQL that needs to perform a search
I'm a bit new to linq and I'm unsure if what I desire is
I'm currently learning a bit more about Linq-To-Entities - particularly at the moment about
I've been reading a fair bit about the performance of using LINQ rather than
Right, bit of a strange question; I have been doing some linq to XML

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.