When using the OnDelete or OnUpdate partial methods in the DataContext (to say, cascade deletes to a child object) you may find that the object itself doesn't get deleted.
This was surprising to me. The reasoning makes sense, though. These partial methods totally replace the regular delete processing. They aren't a "pre" or "post" delete; they are "instead of" delete.
To make the original object actually get deleted, you should call ExecuteDynamicDelete(instance).
As seen here.
Tuesday, May 18, 2010
Tuesday, May 04, 2010
Rhino Expectations should be hit but aren't
I was writing a unit test for a method implemented as a linq query returning IEnumerable and using RhinoMocks to stub out a dependency. Despite all my best debugging efforts where it appeared obvious that the expectations I set should have been met, VerifyAll was throwing with Expected #1 Actual #0.
After lots of head scratching I realized that it's because when calling VerifyAll, nothing had yet enumerated the result of the method call. Linq's laziness had prevented my code from running and therefore meeting my expectations.
After further head scratching, it turns out I've already hit the same problem once before and blogged about it here, so I'm just going to leave this up as a reminder to read your own blog.
After lots of head scratching I realized that it's because when calling VerifyAll, nothing had yet enumerated the result of the method call. Linq's laziness had prevented my code from running and therefore meeting my expectations.
After further head scratching, it turns out I've already hit the same problem once before and blogged about it here, so I'm just going to leave this up as a reminder to read your own blog.
Subscribe to:
Posts (Atom)