views:

31

answers:

0

This is tightly related to a previous question I had. It's a row/column view where columns can be several different datatypes and each row might have a value for each column.

I thought of having the following structure

case

field
    fieldType

bool_values
    fieldId
    caseId
    value

int_values
    fieldId
    caseId
    value

bool_values and int_values are descendant from field in a subclass per table mapping

But I'm having problems setting up the domain model and mapping for this - it might not even be a suitable structure.

Given I have the domain model

class Field
{
  Type;
}

class FieldValue<T>
{
        Case
        T Value
}

class IntegerFieldValue : FieldValue<int>
{
}

class BooleanFieldValue : FieldValue<bool>
{
}

class Case
{
  Dictionary<Field, object> values;
}

How can I map this so I can easily fetch the correct values from case given a field?

This might not be a good design at all though... Hoping someone has some pointers.