Book a Demo

Author Topic: How do i modify the class to save two collections?  (Read 3447 times)

sleek01

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
How do i modify the class to save two collections?
« on: July 18, 2014, 01:16:39 am »
I have the following form that will save Product brands with their models.



What so special about this is, the user could add brands and models separately to gridview controls and save them at once  i.e. Before user clicks save, user may add Brand Names first, then he can add model names for each brand. Then he can save all at once by clicking save.

I have two classes in my Business layer Brand and Model.  There structure is as follows



As you can see the client form has an object that associates with the Brand class “MyBrand”. I can access the “AllMyModels” collection through “MyBrand” and I don’t have an issue with that. But the issue arises when I try to save a collection of Brands with a collection of Models. As you can see In the above form GUI the user can save a collection of brands with their models at once. When this happens the above class diagram breaks because FrmNewBrand does not have a collection of brands, it only has a collection of Model “AllMyModels” through “MyBrand” object.

So how do I modify the above class diagram to save a collection of Brands along with their collection of models at the same time?

thanks

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How do i modify the class to save two collecti
« Reply #1 on: July 18, 2014, 06:49:47 pm »
You need a BrandModel class which aggregates both.

q.