I am developing a module and I understand PetaPoco with single tables within the DNN7 architecture. I still can't quite figure out how I should be handling One to Many Database relationships. I have 3 tables, Product, Options and ProductMappings table, where that table maps the product to many options. For petapoco I have a product class, productcontroller clas, and same thing for the options. Now when I get to the Productmappings table should I have a class and controller class for that or is there another way I should be handling this? I am sure there is an easier way and google searches are not specific enough, they tell me how to get things out of a mappings table (one to many) but don't tell me the right way to populate it. If anyone could lead me in the right direction I would appreciate it.
Asked
Active
Viewed 395 times
0
-
We discussed some ways about doing relationships in this post: http://stackoverflow.com/questions/20503264/petapoco-query-a-sql-server-view/20520474#20520474 – Fix It Scotty Aug 14 '14 at 18:13
-
I think my original question is not clear. I have one product with many options. I have a table for product and a table for option. My third table then has product_id and option_id. I can then link the product to multiple options. Basically I am using a normalized table layout. I need to be able to do CRUD on that third table too. I am not seeing the info I need in that post. – whreed Aug 14 '14 at 19:26
2 Answers
0
You need to have a class, so PetaPoco can map the DB results into objects of that class. A controller is not need if you won't interact with that class from the front-end.

Eduardo Molteni
- 38,786
- 23
- 141
- 206
-
I will interact with the class because I need to save the options. Basically when a user edits the product they will be able to select what options the product has. So I need to have those in the table that will hold the productid with each optionid. – whreed Aug 14 '14 at 19:23
0
On DNN9+ I had no way to get it working except by using a column with "IgnoreColumn" attribute and loading the value from the other entity repository (loop if required)

Mosta
- 868
- 10
- 23