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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:47:43+00:00 2026-05-11T19:47:43+00:00

My application has a very simple model right now and I’m trying to find

  • 0

My application has a very simple model right now and I’m trying to find the best way to traverse through an aggregate. As you can see in my model diagram at the bottom, I have an account, a trip and a list of people attending a trip. I would like to be able to view all of the trips an account is apart of and I have come up with something like this:

    public List<Trip> GetAllTripsFor(int accountid)
    {
        var tripRepository = new TripRepository();
        var trips = tripRepository.FindAll();
        var userTrips = new List<Trip>();

        foreach (Trip trip in trips)
        {
            foreach (TripPeople person in trip.People)
            {
                // If this trip's person list contains this accountid
                // then add this trip to the userTrips list.
                if(person.Account.Id == accountid)
                    userTrips.Add(trip);
            }
        }

        return userTrips;
    }

To me this doesn’t seem very efficient and that I’m not thinking about things correctly. Do any of you have ideas on a better way of implementing this? Perhaps I’m thinking about my model wrong? Thanks

alt text

  • 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-11T19:47:43+00:00Added an answer on May 11, 2026 at 7:47 pm

    thanks for your help. I think I figured out last night what I was trying to achieve. I’m not totally sure it’s the best way but it is working good so far. I was able to come up with an interface like the following:

    //Return a list of trips for the user
    var user = accountRepository.GetUserBy(123);
    var userTrips = user.Trips;
    
    //Return all of the users attending a trip
    var peopleAttendingTrip = tripRepository.GetTripBy(234).People;
    
    //Check user's status for a trip. A user must pay some kind of deposit
    //before they are considered active.
    var userStatus = userTrips.SingleOrDefault().GetStatusFor(user);
    

    To achieve this I created a many-to-many table that holds the the primary keys from User and Trip and then mapped the relationship in NHibernate to the User Class and Trip Class. Also to achieve the user’s status for a trip, I created an Entity that stores the user’s state along with the trip and user info. That’s a little duplication of data it seems like but I like the way it currently works and looks.

    If you guys have any comments or a better way to implement this let me know. I’m always up for improving something! Thanks again

    alt text

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

Sidebar

Ask A Question

Stats

  • Questions 269k
  • Answers 269k
  • 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
  • Editorial Team
    Editorial Team added an answer Basically, for a search of this type (server-side), you need:… May 13, 2026 at 1:12 pm
  • Editorial Team
    Editorial Team added an answer No. I have been bitten by this before. You may… May 13, 2026 at 1:12 pm
  • Editorial Team
    Editorial Team added an answer http://www.eclipse.org/downloads/ May be you need to download C/C++ IDE. May 13, 2026 at 1:12 pm

Related Questions

My application has a very simple model right now and I'm trying to find
I'm trying to write two applications (iphone and desktop) to achieve what's been described
I have a very simple application which consists of an ASP.NET front end site,
My question is how does one abstract a database connection from the model layer
Following the KISS principle , I suddenly realised the following: In .NET, you can

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.