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.

1 Answer 1

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; } } 
Sign up to request clarification or add additional context in comments.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.