Hi,
I got it using ICriteria. Here my solution.
ICriteria crit = session.CreateCriteria(typeof(Order));
crit.Add(Expression.Eq("Id.Type.Id", "new"));
crit.CreateAlias("ItemCollection", "orderIem");
crit.Add( Expression.Eq("orderIem.Type.Id","bundle"));
crit.Add(Expression.Le("orderIem.Created", DateTime.Now));
crit.Add(Expression.Ge("orderIem.Delivered", DateTime.Now));
IList result = crit.List();

It works really great! And incredibly fast ( about 10 Times). Now I
like to create it in a named SQl and struggle with that. But for that
I better open another one
On 13 Feb., 02:36, Ayende Rahien <[email protected]> wrote:
> This is causing a cartesian product between the two order items and orders.Why
> not?
>
> from OrderItem oi
> where oi.OrderId.OrderType.Id in ('new','bundle') ?
>
> On Fri, Feb 13, 2009 at 2:34 AM, antoschka <[email protected]> wrote:
>
> > I probably should add that orderItem has 6000 entities and Order 1200
> > entities
> > I came up with a hql query
> > select o
> > from Order as o, OrderItem as i
> > join i.OrderId as joinView
> > where joinView.OrderType.Id = 'new' and joinView.OrderType.Id =
> > 'bundle'
>
> > Is there something wrong or a better way to do it?
>
> > Thanks antoschka
>
> > On 12 Feb., 23:17, antoschka <[email protected]> wrote:
> > > Hi,
>
> > > I'm struggling with a performance problem and would like create a
> > > query instead of working collections. I'm not very experienced with
> > > queries and don't know which query technique to choose how to
> > > forumlate the query(only some blogs where warned to use hql in
> > > performance critical invironment).
> > > First: what query technique is best for performance critical issues
> > > Second my query problem:
> > > I can narrow it down to two entities which can simplified like that:
> > > Order (columns: Id, OrderType)
> > > OrderItems (columns: Id, OrderId, OrderItemType)
>
> > > I do know the OrderType and OrderItemType and like to get all orders
> > > of the given OrderType which have at least one OrderItem of the given
> > > OrderItemType.
>
> > > Do you have any help for me how to solve that most efficiently.
>
> > > Thank  you so much for your help and effort antoschka
>
>
--~--~---------~--~----~------------~-------~--~----~
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