Djave
Djave

Reputation: 287

Fluent nhibernate mapping

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.

Upvotes: 0

Views: 138

Answers (1)

HuorSwords
HuorSwords

Reputation: 2245

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

Upvotes: 2

Related Questions