开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜