I am new to NHibernate and trying to create my first mapping.
I created such a class (my example is simplified):
public class Buyer
{
public int BuyerID { get; set; }
public string Name { get; set; }
public decimal AverageOrderAmount { get; private set; }
public DateTime LastOrderDate { get; private set; }
}
Typically, to get this data from SQL Server, I would write a query using aggregate functions like this:
select b.BuyerID, b.Name,
avg (o.OrderTotal) as AverageOrderAmount, max (o.OrderDate) as LastOrderDate
from buyers b
join order o at o.BuyerID = b.BuyerID
where BuyerID = @BuyerID
group by b. BuyerID, b.Name
My question is: how do I report this in my comparison? Is it possible?
I suggested that I can save these calculated values in the Buyer's cable and recalculate them as necessary, but this does not seem to be correct.