How can a domain object include a property that calculates a value from other database mapped properties so that the calculated property can be used in both the domain object instance and the db level by nhibernate.linq.
I would like to be able to use the property when working with the object directly:
Console.WriteLine(Entity.Calculated.ToString());
And when working with nhibernate.linq
var q = from e in session.Linq<Entity>()
where e.Calculated > 0
select e;
You need to duplicate the logic in the class and the mapping. Here’s an example:
Class:
Mapping:
Now you can use Linq and query on
Invoice.Balance