sweat!

var multiply = new VarArgsSQLFunction("(", "*", ")");
var quantity_times_unit_factor = Projections.SqlFunction(multiply,
NHibernateUtil.Int64, Projections.Property("quantity"),
Projections.Property("item.unit_factor"));
var sum = Projections.Sum(quantity_times_unit_factor);

On May 1, 4:26 pm, Tuna Toksoz <[email protected]> wrote:
>         var arithmaticAddition = new VarArgsSQLFunction("(", "+", ")");
>         var arithmeticDivide = new VarArgsSQLFunction("(", "/", ")");
>         var arithmaticMultiply = new VarArgsSQLFunction("(", "*", ")");
>         var arithmaticSubstract = new VarArgsSQLFunction("(", "-", ")");
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike
>
> On Fri, May 1, 2009 at 11:26 PM, Tuna Toksoz <[email protected]> wrote:
> > Via Projections.SqlFunction,
>
> > Tuna Toksöz
> > Eternal sunshine of the open source mind.
>
> >http://devlicio.us/blogs/tuna_toksoz
> >http://tunatoksoz.com
> >http://twitter.com/tehlike
>
> > On Fri, May 1, 2009 at 11:13 PM, Jason Meckley 
> > <[email protected]>wrote:
>
> >> the following query fails:
>
> >> var results = DetachedCriteria
> >>        .For<OrderLine>
> >>        .SetProjection(Projections
> >>                .ProjectionList()
> >>                .Add(Projections.GroupProperty("item.category"))
> >>                .Add(Projections.GroupProperty("order.sales_date"))
> >>                .Add(Projections.Sum("quantity*item.unit_factor")))
> >>        .CreateAlias("order", "order")
> >>        .CreateAlias("item", "item")
> >>        .CreateAlias("item.category", "category")
> >>        .Add(Restrictions.Between("order.sales_date", start, end))
> >>        .Add(Restrictions.Eq("order.invoiced", true))
> >>        .GetExecutableCriteria(session)
> >>        .List();
>
> >> with the exception:
> >> could not resolve property: quantity*item.unit_factor of:
> >> SalesReports.Web.Model.Domain.OrderLine
>
> >> however the following HQL works:
>
> >> select
> >>    c,
> >>    h.sales_date,
> >>    sum(d.quantity*i.unit_factor)
> >> from
> >>    OrderLine d
> >>    join d.order h
> >>    join d.item i
> >>    join i.category c
> >> where
> >>     h.sales_date between :start and :end
> >>  and h.invoiced = true
> >> group by
> >>     c.id,
> >>     c.sort_order,
> >>     c.name,
> >>     c.parent_category,
> >>     h.sales_date
>
> >> how do I fix the projection Projections.Sum
> >> ("quantity*item.unit_factor")?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to