Objectfactory & Delete

Objectfactory & Delete

Old forum URL: forums.lhotka.net/forums/t/6432.aspx


rfcdejong posted on Monday, February 16, 2009

Today i started trying to impliment an delete method, ok a bit late but i though it would work as expected. I expected that the delete method would be hit as discribed in the book.

Deferred Deletion (Page 161)

5. b.

When using an ObjectFactory attribute, the data portal creates an instance of the specified object factory class and invokes the specified delete method. This delete method contains the code needed to delete the business object’s data, along with any related child data.

My code:

Persoon
persoon = Persoon.GetPersoon(1097);
persoon.Delete();
persoon.Save();

My Call Stack:

> Framework.Data.dll!U4A.Framework.Data.Factories.U4ABusinessBaseFactory<U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon>.Update(U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}) Line 67 C#

  [Lightweight Function] 

  Csla.dll!Csla.Reflection.MethodCaller.CallMethod(object obj = {U4A.Ceedrie.Data.Relatiemanagement.Factories.PersoonFactory}, Csla.Reflection.DynamicMethodHandle methodHandle = {Csla.Reflection.DynamicMethodHandle}, object[] parameters = {object[1]}) Line 298 + 0x1e bytes C#

  Csla.dll!Csla.Reflection.MethodCaller.CallMethod(object obj = {U4A.Ceedrie.Data.Relatiemanagement.Factories.PersoonFactory}, string method = "Update", object[] parameters = {object[1]}) Line 226 + 0xe bytes C#

  Csla.dll!Csla.Server.FactoryDataPortal.InvokeMethod(string factoryTypeName = "Factory Type=U4A.Ceedrie.Data.Relatiemanagement.Factories.PersoonFactory, Data.Relatiemanagement;Item Type=U4A.Ceedrie.Business.Relatiemanagement.Persoon, Business.Relatiemanagement", string methodName = "Update", object e = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}, Csla.Server.DataPortalContext context = {Csla.Server.DataPortalContext}) Line 77 + 0x3f bytes C#

  Csla.dll!Csla.Server.FactoryDataPortal.Update(object obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}, Csla.Server.DataPortalContext context = {Csla.Server.DataPortalContext}) Line 158 + 0x4e bytes C#

  Csla.dll!Csla.Server.DataPortalSelector.Update(object obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}, Csla.Server.DataPortalContext context = {Csla.Server.DataPortalContext}) Line 110 + 0x10 bytes C#

  Csla.dll!Csla.Server.DataPortal.Update(object obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}, Csla.Server.DataPortalContext context = {Csla.Server.DataPortalContext}) Line 278 + 0xf bytes C#

  Csla.dll!Csla.DataPortalClient.LocalProxy.Update(object obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}, Csla.Server.DataPortalContext context = {Csla.Server.DataPortalContext}) Line 55 + 0x18 bytes C#

  Csla.dll!Csla.DataPortal.Update(object obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}) Line 460 + 0xf bytes C#

  Csla.dll!Csla.DataPortal.Update<Csla.BusinessBase<U4A.Ceedrie.Business.Relatiemanagement.Entities.Relatie>>(Csla.BusinessBase<U4A.Ceedrie.Business.Relatiemanagement.Entities.Relatie> obj = {U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon}) Line 336 + 0x8 bytes C#

  Csla.dll!Csla.BusinessBase<U4A.Ceedrie.Business.Relatiemanagement.Entities.Relatie>.Save() Line 125 + 0x46 bytes C#
  Business.Relatiemanagement.dll!U4A.Ceedrie.Business.Relatiemanagement.Entities.Persoon.Save() Line 85 + 0x8 bytes C#
  Relatiemanagement.dll!

rfcdejong replied on Monday, February 16, 2009

Btw, i forgot to mention that the Immediate deletion works fine. DataPortal.Delete()
It's only the defered deletion which reach the Update method instead of Delete method in de objectfactory.

Kevin Fairclough replied on Monday, February 16, 2009

Deferred deletion will call the Update method, as you have seen.  The update method needs to handle insert/update/delete.

rfcdejong replied on Monday, February 16, 2009

yes, but it's not according what is written in the book on page 161 and 162

JoeFallon1 replied on Monday, February 16, 2009

I think you may be reading that page a little too closely.

"the business developer must provide both a factory class and the business class. The factory class must implement a delete method that ..."

The book doesn't say that the factory delete method will be called. It says you have to have one. I think you just proved the Update method gets called. In there, you have to call your delete method.

Joe

rfcdejong replied on Tuesday, February 17, 2009

Ok, it seems somehow logic to me that the update method is being called. In must then implement another 'target.IsDeleted' in my base class just like i did for target.IsNew and target.IsDirty. The standard Csla-ObjectFactory base class doesn't provide this information.

Still section 5.b on page 161 points out that the specified delete method will be invoked by the dataportal. Maybe im just plain stupid ;)

Anyway maybe it can be added as wish work item on the bug tracker site.

- make IsNew accessable
- make IsDirty accessable
- make IsDeleted accessable

Kevin Fairclough replied on Tuesday, February 17, 2009

Looking at the book 161 5b, the book is wrong, maybe a copy and paste error.

We check the obj.IsXXX properties directly on the BO with the obj being passed to Update.

Copyright (c) Marimer LLC