Why does the creation of the BusinessClass root allow creation with parameters, while in child classes, creation is only allowed without parameters? #3659
Replies: 3 comments 6 replies
-
There are differences between the root and child data portal. One of these differences is that the root data portal invokes data portal operations with attributes like |
Beta Was this translation helpful? Give feedback.
-
Oops, my mistake. In this case, what is the correct way to create and retrieve a child object in Csla 7?" I have a child class that takes its ID from a database sequence, and for this purpose, the child class has a Create method defined as follows: [CreateChild] To invoke this method, I understand that I should do it from a method of the parent, on the client side of the parent class, like Parent.AddChild, which calls a DataPortal method of the parent. Within that method, I invoke the following code: var myChild = dalChild.CreateChild(idSelector); I'm not sure if I'm on the right track, and I'm not sure if it's the simplest way to have a new child object with its ID in the UI to operate with it, add its properties, and then manually add the child object to the parent's list of children. In fact, that child can, in turn, have its own children, and my idea is to create the child objects without having to retrieve the last object added to the parent's children list with code like: var myChildCreated = Parent.ChildList.Last(); What is the correct way to create and retrieve child objects? Any help will be appreciated. Regards, Esteban |
Beta Was this translation helpful? Give feedback.
-
Hello @Chicagoan2016 , Thank you for the suggestion. In fact, I have read the CSLA 4 book, but although in conceptual terms, the creation of the business class follows the same definition, the implementation is very different. I am addressing the issue by using the strategy from the ProjectTracker example, where a helper class 'ProjectResourceEditCreator' is created. So, to retrieve the IDs I need for the child classes, each class is associated with a helper class Creator. |
Beta Was this translation helpful? Give feedback.
-
Hello,
Both of the following methods work for a root class, but if the class is a child, only the first method works:
I invoke the methods from the client with the following methods:
Is there any reason for this difference, or am I doing something wrong?
Any help will be appreciated.
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions