开发者

Filtering on a field that is not included in the mapping in NHibernate

开发者 https://www.devze.com 2022-12-12 03:03 出处:网络
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 Cu

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 man开发者_高级运维y-to-one relationship and I am unsure of how to filter by CustomerID when I load a collection of Orders. Any advice?

Thanks!!


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>();

0

精彩评论

暂无评论...
验证码 换一张
取 消