I’m aware that similar question have been asked here and here and it could probably be a duplicate.
But the question has not been answered in both the places properly so reluctantly, I have to ask it again 🙁
The question is can you use Criteria API to join two tables when there is no mapping available between them.
E.g
class Order{ UserId , OrderId}
class User{UserId , UserName}
and I need to produce a query like,
select user.UserName , order.OrderId from Order order join User user on order.UserId = user.UserId
Please help if anyone is aware of this..and please do note that I need to do it using Criteria or QueryOver techniques
Thanks
/BB
Here is an idea on how it can be done but it is a bit ugly.
Since the mapping does not state that the relationship between Order and User exists therefore it is pretty difficult to have NHibernate generate a join between these two tables.
What you can do instead is do an inner select so your query as SQL would look like this:
This can be done like this on QueryOver:
I have no idea if this is useful at all to you but it is a potential solution to your problem.