It seems to work for me. The product is the parent, and the Ingredient is the Child. He, we hope, will find all products containing this ingredient. I could not fully verify this.
public IList<Product> GetProductsWithIngredient(Ingredient ingredient)
{
using (ITransaction transaction = session.BeginTransaction())
{
ICriteria criteria = session.CreateCriteria<Product>();
criteria.CreateCriteria("Ingredients")
.Add(Restrictions.Eq("GUID", ingredient.GUID));
return criteria.List<Product>();
}
}
Hope this helps :)
NOTE. GUID is my unique identifier.
EDIT: , , . zoidbeck.