0

In my class i have a boolean property:

 public virtual bool IsDefaultPrice
    {
        get;
        set;
    }

I want to set the value of that property in my mapping based on the values of some columns in my db table.

in my table i have two columns : price1 and price2.

I want that if price1 = 0 AND price2 = 0, then IsDefaultPrice = true, otherwise IsDefaultPrice = false.

Can i achieve this through the fluent nhibernate mapping of my class?

Thanks in advance.

Djave
  • 277
  • 1
  • 5
  • 14

1 Answers1

2

If you don't have anything to map on the database, then you only need to create a readonly property that returns true or false in function of your requirements.

public bool IsDefaultPrice
{
    get
    {
         return price1 == 0 && price2 == 0;
    }
}
HuorSwords
  • 2,225
  • 1
  • 21
  • 34
  • +1 this makes sense as a calculated field. If properties are changed at runtime then this field would become out of sync until the entity is re-mapped. – James Jan 18 '13 at 13:47