I'm extracting a parent and related child entities from my DB and
cannot seem to filter the child entities. Here's the code I'm using
(my Parent object is Customer and the child Order):

For simplicity, let's say I'm trying to find customers with surname
Smith, with orders where ProductName= "TV' -

            IList<Customer> customers =
session.CreateCriteria(typeof(Customer))
                .Add(Expression.Eq("Surname", '"Smith"))
                .CreateCriteria("Orders")
                .Add(Restrictions.Eq("ProductName", "TV"))
                .SetResultTransformer(new
DistinctRootEntityResultTransformer()) //remove duplicate parent
entries
                .List<Customer>();

This returns me a list of distinct customers, however I always get ALL
orders for the retrieved customers. Is there something else I need to
apply to activate the filter on orders? The NHibernate documentation
mentions using SetResultTransformer(CriteriaUtil.AliasToEntityMap)
here:

http://nhforge.org/doc/nh/en/index.html#querycriteria-associations
However this has been removed from the latest version of NHibernate. I
tried using what appeared to be the equivalent, which is:

SetResultTransformer(new AliasToEntityMapResultTransformer())

But I still get all Orders returned. Any ideas?

-- 
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