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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:51:17+00:00 2026-06-13T02:51:17+00:00

In the database I have 3 tables, User, Group and a lookup table UserGroup

  • 0

In the database I have 3 tables, User, Group and a lookup table UserGroup which contains UserID and GroupId.

I create a model.edmx and this allows me to:
var users = context.User
var groups = context.Group
but does not create an object for context.UserGroup.

what is the syntax for getting all the users in a group, and all the groups that a user belongs to?

var results = from groups in db.Groups.Where(t => t.Users(u => u.UserID ==1))
select groups;
  • 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-13T02:51:17+00:00Added an answer on June 13, 2026 at 2:51 am

    If you have the proper keys setup, EF will hide away your junction table, and create a navigation property to make the connection between the tables

    For getting all the groups a user belongs to:

    var groupResults = db.Groups.Where(g => g.Users.Select(u => g.UserId).Contains(userId));
    

    and for getting all the Users:

    var userResults = db.Users.Where(u => u.Groups.Select(g => g.GroupId).Contains(groupId));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database named Tamaris, which contains a table User. I created a
I have two tables in my database: user and media_contact . The media_contact table
I have a database in which there is a user table & how many
I have 3 tables in my database Group [GroupId, GroupName] GroupUser [GroupId, AuthorId] Author
I have a PostgreSQL database with two tables named user and group. They have
In a database I have the tables User , Group and UsersInGroup and generate
i have in the database typical tables like user, usergroup, and they have relations.
I have two tables in my database first saveimage which contains id and url
I have two tables in my database who looks like this: User: userid(int) username(varchar)
Imagine we have two tables in the database, user (FK id_role) and role (PK

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.