views:

31

answers:

1

I have an NH query which returns a Product with a BasePrice. Depending on various other factors, such as Manufacturer price markup, I use a PricingService on the C# side of things to produce a "final" price.

The issue is that I now need to query against this final value - i.e., I need to run a query that selects Products within a particular "final" price range, but because that value only exists on the C# side, I can't do an NH query against it.

I'm thinking that my approach to this is all wrong, but I really didn't want to put the logic of the final price calculation in a SQL function or something like that, so any suggestions would be appreciated.

+1  A: 

You can do your calculations in HQL or Linq (with the new provider in 3.x; the 2.x one is a little limited).

Diego Mijelshon
??Can you show some examples of that? Are you saying you can use C# methods inside your HQL queries?
Lewis
No, you can't use C# methods. But you *can* do projections and calculations that include other entities, inject the calculation parameters, etc.
Diego Mijelshon