Question

I am testing a user-defined override to BeforeSaveEntities on the Breeze Server Side. I have a breakpoint where I am observing the saveMap, and I call a method on the sub-class of the EFContextProvider to loop through each entity being saved.

Then when I click the Debug Stop button in Visual Studio, the Save still occurs. If I change the return from BeforeSaveEntities return from passing back the original saveMap to null, it does not.

This was a bit unsettling when I was going to "test" deleting...as I'm trying to write code that will do a "soft" delete.

Anyway, my question is, is there a workaround so I don't have to setup a "return null" during testing?

But more importantly, if I throw an EntityErrorsException it does stop the save as expected. :)

Thanks. Bob

Was it helpful?

Solution

This happens because you are just detaching the Visual Studio debugger from the running IIS/IIS Express instance. As soon as you detach the debugger, the request's execution continues on the webserver and thus, the rest of the code is executed.

A quick workaround would be to wrap your null return code in a compiler condition and check for the DEBUG symbol. Something along these lines:

#if DEBUG
    return null;
#endif

Production code should be built using the RELEASE compiler symbol instead of the DEBUG symbol to enable deletion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top