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

The Archive Base Latest Questions

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

for a project i’m currently working on, im trying to pass a set of

  • 0

for a project i’m currently working on, im trying to pass a set of objects all somehow linked to one object.

I’m currently blacked out and can’t seem to find a proper solution.

The situation is like this. I have a product object, on which a few insurance packages apply. I need to pass this information to the view, but I have to be able to retrieve the proper packages for the proper products. so it looks like this…

Product 1 has package 1, 2, 3
Product 2 has package 2,3,5,6
Product 3 has package 2,4,6,7

The problem is that there can be a different number of products and a different number of packages

Any ideas? The answer is probably simple, but I’m a little bit too tired to find it out…

  • 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-11T21:03:03+00:00Added an answer on May 11, 2026 at 9:03 pm

    How about this:

    • Create a container class, as Simon suggested
    • Inside the class, have these members:
      • List Products { get; set; }
      • List Packages { get; set; }
      • List GetPackages(Product product);

    The GetPackages method can query the internal dictionary to determine which packages to return.

    public class ProductsPackages
    {
        private Dictionary<int, int> _map;
    
        public ProductsPackages(List<Product> products, List<Package> packages,
                                Dictionary<int, int> map)
        {
            _map = map;
        }
    
        public List<Product> Products { get; private set; }
        public List<Package> Packages { get; private set; }
    
        public List<Package> GetPackages(Product product)
        {
            return (from p in Packages
                    join kvp in _map on p.ID == kvp.Value
                    where kvp.Key == product.ID
                    select p).ToList();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A project I'm working on at the moment involves refactoring a C# Com Object
My project needs to have a number of administrators, out of which only one
A project I have been working on for the past year writes out log
My project is currently using a svn repository which gains several hundred new revisions
The project I'm working is using n-tier architecture. Our layers are as follows: Data
Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on
The project I'm working on allows an end-user to modify CSS code to integrate
My project is made out of lots of bits and pieces of older code.
My project has all the visual studio solutions and projects stored in ./win/vc100, sources
I project I have been working on has now been split between me and

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.