0
votes

I have Customers and orders table.

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

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

I want to remove child ie. Orders from the NhSession. Presently I am doing.

NhSession.Delete(orders) which is giving me the error. deleted object would be re-saved by cascade (remove deleted object from associations)

Is that I have do some mapping changes in order to delete the child ?

1

1 Answers

0
votes

reset the association in code which always preferable to not have a broken model

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