2013-07-12 24 views
0

我有客戶和訂單表。使用nhibernate nhsession刪除子行

Customers 
--------- 
CustomerId | OrderId 
1   | 1  
2   | 2  

Orders 
------- 
OrderId | Amount 
1  | 24 
2  | 25 

我想刪除孩子即。來自NhSession的訂單。 目前我在做。

NhSession.Delete(orders)給我的錯誤。 已刪除的對象將被級聯重新保存(從關聯中刪除已刪除的對象)

是我爲了刪除子項而做了一些映射更改?

回答

0

復位代碼的關聯總是優選沒有破壞的模型

NhSession.Delete(customer.Order); 
customer.Order = null; 
NhSession.Flush();