hi! i'm trying to solve this problem still.. but can't think of
anything. could somebody please show me how it should be done?
the domain model is classic customer, order, orderitem, product..
somebody, please?
ISQLFunction arithmeticMulti = new VarArgsSQLFunction("(",
"*", ")");
DetachedCriteria order_orderitems_projection =
DetachedCriteria.For<OrderItem>()
.SetProjection(
Projections.ProjectionList()
.Add(Projections.Sum(Projections.SqlFunction(arithmeticMulti,
NHibernateUtil.GuessType(typeof(decimal)),
Projections.Property("Price"), Projections.Property("Quantity"))),
"OrderAmmount")
.Add(Projections.GroupProperty("Order.Id"),
"Id")
)
//.Add(Expression.Ge("OrderAmmount", ammount)) //fails-
NHibernate.QueryException : Could not find property OrderAmmount
;
var list =
_session.CreateCriteria<Customer>().CreateCriteria("Orders").Add(Subqueries.PropertyIn("Id",
order_orderitems_projection)).List<Customer>();
going for this SQL:
select distinct cust.* from Test.dbo.Customer cust inner
join Test.dbo.[Order] ord on ord.CustomerId = cust.Id
where
ord.Id in (
select A.Id
from
(select ord.Id as Id, SUM(oi.Price * oi.Quantity) as
OrderAmmount from Test.dbo.[Order] ord inner join Test.dbo.OrderItem
oi on ord.Id = oi.OrderId group by ord.Id) A
where A.OrderAmmount > @ammount
)
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.