Hi,
I am trying to implement a logical delete senario across all my entities. All have an IsDeleted boolean property. I would also like to cascade the association deletes also. I started by adding a partial method for the entity to the datacontext.
partial void DeleteQuestion(Question instance)
{
instance.IsDeleted = true;
ExecuteDynamicUpdate(instance);
foreach (var answer in instance.Answers)
{
DeleteAnswer(answer);
}
}
This throws an error Incorrect syntax near the keyword 'WHERE'
at ExecuteDynamicUpdate. Looking at sql profiler I can see the set clause is blank, it is not recording the IsDeleted = true;
as a change. I checked the IsDeletedChanging event and it does get fired but I guess the change set has been built already by this time.
I also tried submitting the changes instead of calling ExecuteDynamicUpdate but this throws the exception The operation cannot be performed during a call to SubmitChanges.
I have seen an identical discussion here with the only resolution being to use stored procedures which I would rather not do.
So I thought lets ask the SO community and get a proper answer to the top of the Google results. There seems to be little on this topic.
Many thanks.