I'm trying to implement Soft Delete for my dependent objects. I have a data model similar to:
public class Order {
public IEnumerable<OrderItem> Items {get; set;}
}
public Order Item {
public Order {get;set;}
public bool IsDeleted {get;set;}
}
I'm using DB first, and have used the fluent-api within OnModelCreating to successfully filter out any OrderItem's that have the IsDeleted flag set.
When the OrderItem is removed from the Order's Item collection, and the Order is saved, the OrderItem is hard deleted from the database. I've been unable to find a hook that will allow me to indicate that the OrderItem should actually be updated with the IsDeleted flag set to true instead of being hard deleted.
I would expect that this is a fairly common use case, but for the life of me I have not been able to find the solution. Any thoughts/ideas would be appreciated.