Basically, I mix EF with a single call to a stored procedure that does some batch deletion, otherwise EF is too slow.
Here is some kind of pseudo-code for this scenario (in reality I have more complex code):
public void RemoveCustomer(int customerUID)
{
{
var orders = repoOrders.GetOrdersOfCustomer(filter, customerUID);
repoX.DoSomethingWithOrders(orders);
repoOrders.DeleteAllOrdersOfCustomer(customerUID);
repoCustomers.DeleteCustomer(customerUID);
}
}
Of course, customer orders are a ratio one-to-many(1: m).
I want to avoid the exception in the above scenario that occurs when some orders loaded by the context belonging to the client are deleted. The exception is:
" , NULL. , . , , ."
, , / <DbSet>.Local - , .
, Detach , , .
?
: EF, EF , ADO.NET, , BL ... .
. .