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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:06:27+00:00 2026-06-11T16:06:27+00:00

So, that’s my model .. nice and complex. I’m looking to get Areas by

  • 0

entity model

So, that’s my model .. nice and complex.

I’m looking to get Areas by a UserID. If I were doing this in SQL, I would do a bunch of joins all the way up to the Users table. How would you do this in LINQ query syntax or method chaining?

I can do this pretty straightforward from the other way around, but then I have to do a lot of extra work to flatten the resulting graph and it also requires pulling back all the entities in between.

If I can optionally include AreasPermissions & Permissions, that would be gravy .. but at this point I wouldn’t mind an additional query to fetch those.

Another option I was floating was using a function import to a sproc and map that to an Area .. but when I start needing to include other entities it makes that option less elegant. I’m also trying to avoid using sprocs just to use sprocs because it’s always a slippery slope with folks .. ‘use a sproc for one thing’ tends to mold into ‘don’t use EF (table access) for anything’.

var userByID = new Func<User, bool>(x => x.UserId.Equals(userID, StringComparison.InvariantCultureIgnoreCase));
var user = this._context.Users
    .Include("TeamsUsers.Team.TeamsRoles.Role.RolesAreasPermissions.AreaPermission.Area")
    .Include("TeamsUsers.Team.TeamsRoles.Role.RolesAreasPermissions.AreaPermission.Permission")
    .Single(userByID);
  • 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-11T16:06:28+00:00Added an answer on June 11, 2026 at 4:06 pm

    I have no way of testing this, but I think it should work:

    var result = 
        from user in _context.Users
        where user.Id == userId
        from teamUser in user.TeamUsers
        from teamRole in teamUser.Team.TeamRoles
        from roleAreaPermission in teamRole.Role.RoleAreaPermissions
        select roleAreaPermission.AreaPermission.Area;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's how I'm new in here on the website so it would be super
That one is a tricky one I believe. I would like to merge two
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That should be simple web site but with an editable tree. This tree will
That show up on menu bar It's like this question: How to create a
I am doing a simple coin flipping experiment for class that involves flipping a
That is, is there ever a case where a domain model should be available
That is, why does this: struct S {}; struct T { T(S& s) :
That is my table #EmployeeTemp . What I would like to do is retrieving

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.