0

I have a module that deals with Products and Options. Where an a product can have multiple options.

So say I have a poco class of (partial information here)

class Product
{
    public int ProductId { get; set; }
    public string ProductName { get; set; }

I then have a class for options...

public class Option
{
    public int OptionId { get; set; }
    public string OptionName { get; set; }
    public int OptionImage { get; set; }

I then have a table in my db that maps the two together . What is the strategy of say when I pull back the two in a view but how do I have a poco class that would update the mapping table? Because say for example I can have a poco class of

class Mappings
{
    public int MappingId { get; set; }
    public int ProductId { get; set; }
    public int OptionId { get; set; }

But say my view pulls back the actual product name and option name that are not in the mappings class/table. Do I then just create a product class with the ID I get back in the Mappings class and do another db call to produce the name or do I make the mappings class handle the name? Just trying to see how other developers have handled this.

whreed
  • 133
  • 1
  • 11

2 Answers2

0

I found that if I create a view which has my mapped id's to their corresponding named values, I can then set up my poco class as having [ReadOnlyColumn] values and this solves my issue for poco updates. Hope this helps someone, otherwise I will respond if you need help.

my mappings class would be...

public int MappingId { get; set; }
public int CategoryId { get; set; }
public int OptionId { get; set; }
[ReadOnlyColumn]
public string CategoryName { get; set; }
whreed
  • 133
  • 1
  • 11
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)

note: tried ReadOnly Column but it does not load the external column (value always null)

Mosta
  • 868
  • 10
  • 23