且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NHibernate-无需映射即可加入

更新时间:2023-12-05 19:56:40

我不知道标准版本,但是在HQL中,您可以这样做:

I don't know the criteria version, but in HQL you can do it like this:

select customer, order from Customer customer, Order order 
    where order.CustomerID = customer.Id
    and customer.Id = 42

然后,结果集将是object []的列表,在该列表中,客户将被重复乘以其下达的订单数(当然,假设有很多订单中有一位客户).

The result set will then be a list of object[] where the customer will be repeated times the number of orders he has placed (assuming of course that there is one customer to many orders).

请注意,如果没有任何订单,结果将为空.

Please note that the result will be empty if there aren't any ordes.