Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Nested Collections

Nested Collections

Scheduled Pinned Locked Moved C#
helptutorialquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xfitr2
    wrote on last edited by
    #1

    I have been struggling with this for a while now and thought it was time to post it to the forum. I have a class library with nested collections. Each collection can contain an employee collection. The employee objects in each nested collection's employees collection can have different properties and different values. My problem is some of the properties will always be the same like FirstName, LastName, etc. Therefore I know that I need to have a main employee collection that all the other employee objects reference so that when I change the firstname all the employee's collections that contain that employee will update the firstname. How do I add an employee collection to each nested collection that references a main employee collection's employee, but I can change some employee properties in each nested collection that are unique to that class. I hope this was not too confusing. Below is a simple example of what I have done and it works correctly so far except for it creates a new object for the same employee for each employee collection. Entities |-Entity ..|-Employees.Employee ..|-Divisions ....|-Division ......|-Employees.Employee ......|-Groups ........|-Group ........|-Employees.Employee Employee |-FirstName |-LastName |-SomeProperty (Could be unique for each nested collection) Any help would be appreciated. -Garrett

    M 1 Reply Last reply
    0
    • X xfitr2

      I have been struggling with this for a while now and thought it was time to post it to the forum. I have a class library with nested collections. Each collection can contain an employee collection. The employee objects in each nested collection's employees collection can have different properties and different values. My problem is some of the properties will always be the same like FirstName, LastName, etc. Therefore I know that I need to have a main employee collection that all the other employee objects reference so that when I change the firstname all the employee's collections that contain that employee will update the firstname. How do I add an employee collection to each nested collection that references a main employee collection's employee, but I can change some employee properties in each nested collection that are unique to that class. I hope this was not too confusing. Below is a simple example of what I have done and it works correctly so far except for it creates a new object for the same employee for each employee collection. Entities |-Entity ..|-Employees.Employee ..|-Divisions ....|-Division ......|-Employees.Employee ......|-Groups ........|-Group ........|-Employees.Employee Employee |-FirstName |-LastName |-SomeProperty (Could be unique for each nested collection) Any help would be appreciated. -Garrett

      M Offline
      M Offline
      MIHAI_MTZ
      wrote on last edited by
      #2

      Probably the most logical way would be to have an Employee class and than inherit from it specific Employee types.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups