Instead of using the above method I use the FlushEntity event to set
the reference to null when it has the default value, and the LoadEvent
to set the reference to the NoTaxCalculator when the value is null.
That works like a charm...

On Jun 10, 7:11 pm, David Perfors <[email protected]> wrote:
> Well, this doesn't solve he problem... I am not trying to inject a
> specific TaxCalculator, I save a reference to a specific
> TaxCalculator. The referencing part work, except when I want to use
> the NoTaxCalculator class, which is not in the database, because it
> should not be modified by the user.
>
> class TaxCalculator
> {
>     public static TaxCalculator NoTaxCalculator = new TaxCalculator
> ("No Tax", 0);
>     public TaxCalculator() {}
>     public TaxCalculator(string name, double percentage) { Name =
> name; Percentage = percentage; }
>     public Guid Id { get; private set; }
>     public string Name { get; set; }
>     public double Percentage { get; set; }
>     public double CalculateTax(double fromMoney) { return fromMoney *
> Percentage; }
>
> }
>
> class Input : DomainEntity
> {
>     public Input() { TaxCalculator = TaxCalculator.NoTaxCalculator; }
>
>     public Guid Id { get; private set; }
>     public string Name { get; set; }
>     public TaxCalculator { get; set; }
>     public double Value { get; set; }
>
> }
>
> On Jun 9, 5:01 pm, Fabio Maulo <[email protected]> wrote:
>
> >http://fabiomaulo.blogspot.com/2008/11/entities-behavior-injection.html
>
> > 2009/6/9 David Perfors <[email protected]>
>
> > > Hi,
>
> > > In our domain we can make calculations and we can use VAT tables when
> > > necessary. We do this by making a reference from an item to the table.
> > > When the user don't want to use a VAT table it selects the "No VAT"
> > > table. The NoVAT is a default entity that should always exists (it is
> > > now hardcoded in our code) and the user should not be able to change
> > > this default entity.
>
> > > What is the best solution to do this using NHibernate? I can lay a
> > > reference to the VATTables, but it will complain when using the
> > > default table.
>
> > > Any suggestions?
>
> > --
> > Fabio Maulo
>
>
--~--~---------~--~----~------------~-------~--~----~
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