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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:03:11+00:00 2026-05-11T02:03:11+00:00

i have in the database typical tables like user, usergroup, and they have relations.

  • 0

i have in the database typical tables like user, usergroup, and they have relations.

in my domain-model i want that if you request users, you will get the users and each user has the property belongsto, which means these are the groups he belongs to. in the property i want to have the list of groups (typesafe as groups)

the same should be done on the other hand, that means each group should know which users belong to the group.

i have this classes (example):

public class User {     int Id { get; set; }     string Name { get; set; }     List<Usergroup> BelongsTo { get; set; }      User()     {         BelongsTo = new List<Usergroup>();     } }  public class Usergroup {     int Id { get; set; }     string Name { get; set; }     List<User> Users { get; set; }      Usergroup()     {         Users = new List<User>();     } }  internal class Relation {     int userId;     int groupId; } 

now, whats the best way to implement it, and whats the fastest way to get all objects filled.

btw: i’m using subsonic to get all the database-records (for each table one select). and there are at least 1500 user and 30 groups.

my current code is based on foreach over the groups, relations.where for the groups, and then users.singleordefault to find the user and then add the user to the group and the group to the user. but it takes appx 30secs to do this.

my client-app is a webapp, so i store the results after all in a cached repository, thats why i’m doing it in this way!!

  • 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. 2026-05-11T02:03:12+00:00Added an answer on May 11, 2026 at 2:03 am

    my current code is based on foreach over the groups, relations.where for the groups, and then users.singleordefault to find the user and then add the user to the group and the group to the user.

    I don’t understand what you’re saying here.

    it takes appx 30secs to do this

    Whatever it is you’re doing seems too slow, given there’s only 1500 users and 30 groups.

    now, whats the best way to implement it, and whats the fastest way to get all objects filled.

    If you wanted …

    • Either, all users, with the groups for each user
    • Or, all groups, with the users for each group

    … then I might suggest selecting joined records from the database.

    However, because …

    • You want all data (joined in both directions)
    • You only have 1500 records

    … then I suggest that you select everything as simply as you can, and join in it your application.

    //select users Dictionary<int, User> users = new Dictionary<int, User>(); foreach (User user in selectUsersFromDatabase()) {   users.Add(user.Id, user); } //select groups Dictionary<int, Group> groups = new Dictionary<int, Group>(); foreach (Group group in selectGroupsFromDatabase()) {   groups.Add(group.Id, group); } //select relations //and join groups to users //and join users to groups foreach (Relation relation in selectRelationsFromDatabase()) {   //find user in dictionary   User user = users[relation.userId];   //find group in dictionary   Group group = groups[relation.groupId];   //add group to user and add user to group   user.BelongsTo.Add(group);   group.Users.Add(user); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 76k
  • Answers 76k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Just extend your Course entity with a new property. The… May 11, 2026 at 3:00 pm
  • added an answer I created a set of JavaBean annotations to generate property… May 11, 2026 at 3:00 pm
  • added an answer You need to create threads in each simulation cycle? That… May 11, 2026 at 3:00 pm

Related Questions

In a web application like wiki or forums or blogging software, it is often
I have two tables in my database, called ratings and movies . Ratings: |
I know that that is not a question... erm anyway HERE is the question.
Background I am working on a legacy small-business automation system (inventory, sales, procurement, etc.)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.