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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:18:12+00:00 2026-05-23T10:18:12+00:00

In my database, I have a user table and a workgroup table, and a

  • 0

In my database, I have a user table and a workgroup table, and a many-to-many relationship. A user can belong to one or more workgroups. I am using entity framework for my ORM (EF 4.1 Code First).

User Table has users:

1,2,3,4,5,6,7,8,9,10

Workgroup table has workgroups:

A,B,C, D

WorkgroupUser table has entries

A1, A2, A3, A4, A5
B1, B3, B5, B7, B9
C2, C4, C6, C8, C10
D1, D2, D3, D9, D10

What I would like to do is:
Given user 4, it belongs to workgroups A,C
and has common users

1,2,3,4,5 (from workgroup A) and 
2,4,6,8,10 from workgroup C

and the distinct set of users in common is 1,2,3,4,5,6,8,10

How do I write a LINQ statement (preferably in fluent API) for this?

Thank you,

  • 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-23T10:18:13+00:00Added an answer on May 23, 2026 at 10:18 am

    Here’s the general idea (since I don’t know the properties of User and WorkGroup entity)

    var result = context.users.Where(u => u.ID == 4)
                              .SelectMany(u => u.WorkGroups.SelectMany(wg => wg.Users))
                              .Distinct()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i am using GORM and i have an user table in database. also
I have a user table in my mysql database that has a password column.
I have a postgres database with a user table (userid, firstname, lastname) and a
I have a USER table in database. The table has a RegistrationDate column which
I have a user table in my database which contains two columns FirstName and
I have a User table and a ClubMember table in my database. There is
I have a User table in my Postgres database. In my application, the User
I have a user table in postgress. Each user can have from 0 to
I have a database setup with many tables. To Find a User's Computer it
I have a huge database. In this Database I have a User-Table. In this

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.