views:

104

answers:

1
SELECT O.*, P.* FROM ORDERS O, PRODUCT P WHERE O.ORDER_ID=P.ORDER_ID;

What would be the Criteria representation of the above query?

+3  A: 

If you have something like this:

public class Order
{
   public virtual ISet<Product> Products {get;set}
}

You need to do

session.CreateCriteria(typeof(Order))    
    .SetFetchMode("Products", FetchMode.Eager)    
    .List();

That's it.

Krzysztof Koźmic