2013-08-23 62 views
1

我有工作,但實在是太慢了下面的查詢,因爲它是採用:休眠刪除與連接而不需要使用

_session.CreateQuery(@" 
    delete OrderItem oi 
    where oi in 
     (select i 
      from OrderItem i 
      where i.Product.Id = :productId 
      and i.Order.Company.Id = :companyId 
      and i.Order.Campaign.Id :campaignId 
      and i.Order.OrderStatus = :orderStatus) 
    ") 
    .SetParameter("productId", productId) 
    .SetParameter("companyId", companyId) 
    .SetParameter("campaignId", campaignId) 
    .SetParameter("orderStatus", orderStatus) 
    .ExecuteUpdate(); 

有沒有辦法使用,你可以簡單地使用連接本機查詢方式刪除像:

DELETE posts 
FROM posts 
INNER JOIN projects ON projects.project_id = posts.project_id 
WHERE projects.client_id = :client_id 

回答