tags:

views:

103

answers:

1

Situation (following are entities):

public class OrderItem
{
...
      public Order Order
...
}

public class Order
{
...
      public Customer Customer
....
}

public class Customer
{
      public int Id
}

Question: how to create criteria, which gives me all OrderItems for some Customer id?

+2  A: 
ICriteria criteriacrit = session
  .CreateCriteria<OrderItem>())
  .CreateAlias("Order", "order")
  .CreateAlias("order.Customer","customer")
  .Add(Expression.Eq("customer.Id",id));

May not be exact for your model, but this should get you started. Link.

mxmissile
Nailed it, 10x a lot!
Danail