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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:27:19+00:00 2026-05-23T05:27:19+00:00

I have five tables all with a primary key of ID User User_Role_Relation with

  • 0

I have five tables all with a primary key of ID

  • User
  • User_Role_Relation with Foreign Keys User_ID and Role_ID
  • Role
  • Role_Right_Relation with Foreign Keys Role_ID and Right_ID
  • Right

I am currently getting the Rights for the selected User with the following query in a stored procedure

  SELECT DISTINCT 
      tbl_Right.ID, tbl_Right.Name    
  FROM 
      tbl_User_Role_Relation 
  INNER JOIN 
      tbl_Role_Right_Relation ON tbl_User_Role_Relation.Role_ID =  tbl_Role_Right_Relation.Role_ID 
  INNER JOIN 
      tbl_Right ON tbl_Role_Right_Relation.Right_ID = tbl_Right.ID
  WHERE 
      tbl_User_Role_Relation.User_ID = @User_ID

I am trying to covert this to LINQ to Entity with this code

var query = from r in context.Rights
            from rrr in r.Role_Right_Relation
            from rl in rrr.Role
            from urr in rl.User_Role_Relation
            where urr.User_ID == userid
            select r;

but I get the following error

An expression of type ‘Models.Role’ is not allowed in a subsequent from clause in a query expression with source type ‘System.Linq.IQueryable’ Type inference failed in the call to ‘SelectMany’

Any advise would be helpful.

Thanks.

  • 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-23T05:27:19+00:00Added an answer on May 23, 2026 at 5:27 am

    First of all that linq query is doing a cross join, not inner join like your sql. You should check out this

    Second of all, you would probably be best correctly defining the relationships between entities in the edmx and you probably won’t have to join at all, instead you can use navigation properites to access parent/children and filter on those properties directly

    The idea of the entity framework is you don’t have to flatten the hierarchy

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

Sidebar

Related Questions

I have five models and their respective tables are Member:id,fname,lname Student:id,member_id(foreign key references member
I have five tables: User user_id | name -------------------- 0 | Mark 1 |
I have five tables: tab_template template_group group user_group user Tab_template's are organized into groups
I have five tables in my database. Members, items, comments, votes and countries. I
I have five tables that are fairly similar in structure but different enough that
I have a MySQL database with a few (five to be precise) huge tables.
I have Five check boxes Search All Template 1 Template 2 Template 3 Template
I have five tables: models : id, name, specification models_networks : id, model_id, network_id
I have the following five tables: ISP Product Connection AddOn AddOn/Product (pivot table for
Lets say I have five tables named table1, table2 ... table5. I have already

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.