I have the following hql. This works fine if i don't try and include the "OrderItem" entity. I understand that there is no "on" clause in hql. What is the best way to join orderItem
var hql = new StringBuilder();
hql.Append(
@"select p.Id, p.Name, p.Description, p.ProductKey, p.CustomerSku, p.ImageUrl, p.ImageThumbUrl, p.ImageLargeUrl,COUNT(oi.Quantity) as quantity
from ProductCampaign pc
join pc.Product p
left join OrderItem oi with oi.Product.Id = p.Id
where pc.Campaign.Id = :CampaignId ");
hql.Append(@"group by p.Id, p.Name, P.Description, p.ProductKey, p.CustomerSku, p.ImageUrl, p.ImageThumbUrl, p.ImageLargeUrl ");
var results = _session.CreateQuery(hql.ToString());
results.SetParameter("CampaignId", campaignId);
Here is the sql i wish to achieve.
select p.Id, p.name, p.description, p.ProductKey, p.CustomerSku, p.ImageUrl, p.ImageThumbUrl, p.ImageLargeUrl,COUNT(oi.Quantity) as quantity from ProductCampaign pc
inner join Products p on pc.ProductId = p.Id
left join orderitems oi on pc.ProductId = oi.ProductId
where pc.CampaignId = 1
group by p.Id, p.name, p.description, p.ProductKey, p.CustomerSku, p.ImageUrl, p.ImageThumbUrl, p.ImageLargeUrl