I've got the following class structure:

class Aggregate{
  int id;
  string name;
  IList<ItemBase> Items {get; set;}
}

abstract class ItemBase {}

class Item1 : ItemBase {
  decimal value;
  string key;
}

class Item2 : ItemBase{
  int range;
  DateTime time;
}

... // total of 5 item types

My DB schema (legacy, no changes possible) is as follows:

id,
name,
-- Item1 fields
value,
key,
-- Item2 fields
range,
time,
... // other columns to hold values for the rest of item types

So, now I have to be able to load this Aggregate with items as a part
of a list. There is finite number of  "items" in the schema (5) and
the only way to map it that I came up with so far is to have something
like this:

class Aggregate{

  private Item1 _item1{
    set {
      Items.Add(value);
    }
  }

  int id;
  string name;
  IList<ItemBase> Items {get; set;}
}

And I map this via <component> mapping:

<component name="_item1" class="Item1">
 <property name="value" .../>
 <property name="key" ... />
</component>

This works for loading only, but it is ugly and definitely not how I
should approach this problem - it pollutes my domain entities with
totally artificial constructs. Even more - when columns for a
particular Item are all NULL I shouldn't add it to the list (I can do
that using this hack approach I've got now).

I would really appreciate if anyone could point me in the right
direction.

Thanks a lot!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to