[Sorry, I accidentally posted my question before it was finished]

To paraphrase my question, so that it will have more context:

I have a need to store different collections of pricing information or
hourly rates.

For a given entity (say, an Employee), I will have: HourRates,
ExternalHourRates, EventHourRates and so on.
Some of the rates will be stored without a parent entity (like global
pricing information).

Each type of  "rate" is holds these four values:
Valid from, Valid to, Amount, Created.

I tried to model my entity like so:
class AmountInfo
{
   public virtual DateTime Created { get; set; } // defaults to
DateTime.Now
   public virtual DateTime ValidFrom  { get; set; }
   public virtual DateTime ValidTo { get; set; }
   public decimal Amount { get; set; }
}

class Employee
{
  public virtual ISet<AmountInfo> HourRates { get; set; }
  public virtual ISet<AmountInfo> ExternalHourlRates { get; set; }

}

but NHibernate would create just one table and put them all inside
that table. So HourRates and ExternalHourRates were efectively the
same.

Then, I introduced subclasses:

public class HourRate : AmountInfo {}
public class EventHourRate : AmountInfo {}

Now I was getting somewhere. I'm using FNH to configure the mappings
and it defaults to table-per-subclass, so I ended up with many tables.
I modified configuration to use table-per-class-hierarchy later on,
with some success.

The troubles I'm having is that I can't figure out a way to:

- query for last HourRate (based on Created timestamp) for a given
entity
- with table-per-subclass-hierarchy, I couldn't query on subclasses --
I was getting WrongClassException because NH didn't issue where clause
to filter on "type" column for a specific type.
- what is the best mapping strategy for this kind of scenario -- and
how to best model this in OO so that NHibernate picks it up as
smoothly as possible?

Thanks,
  Miha.

On Aug 9, 5:46 pm, Miha V <[email protected]> wrote:
> Hi!
>
> I have a one-to-many association between several entities. That's also
> the reason I'm not using bidirectional mapping.
> [...]

-- 
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