tags:

views:

21

answers:

1

Hello, I have an Order object that has a Customer child object. Before I did not have a many-to-one relationship set up and I was simply returning the CustomerID. With that approach I could easily filter by CustomerID. Now I set up a many-to-one relationship and I am unsure of how to filter by CustomerID when I load a collection of Orders. Any advice?

Thanks!!

+1  A: 

I think that you are after sothing like the following

IList<Order> orders = Session.CreateCriteria(typeof(Order))
.CreateCriteria(typeof(Customer))
.Add(Expression.Eq("CustomerId", customerId))
.List<Order>();

Nathan Fisher
That was the case. I didn't realize you could call CreateCriteria twice. Pretty cool stuff. Thanks!!
Mike C.