How do I create objects in the UI with IsChild = true to add them to a BusinessListBase? #4107
Unanswered
ecaldentey
asked this question in
Questions
Replies: 1 comment
-
Is your question that you are trying to add a new item to a To create a child you need to use the child data portal. When you need to do this from the client, the normal solution is to use a command object to go to the server, create the child, and return it. public class MyChild : BusinessBase<MyChild>
{}
public class MyChildFactory : ReadOnlyBase<MyChildFactory>
{
public static readonly PropertyInfo<MyChild> MyChildProperty = RegisterProperty<MyChild>(nameof(MyChild));
public MyChild MyChild
{
get => ReadProperty(MyChildProperty);
set => LoadProperty(MyChildProperty, value);
}
[Create]
private async Task Create([Inject] IChildDataPortal<MyChild> portal)
{
MyChild = await portal.CreateChild();
}
}
// calling code, having access to an IDataPortal<MyChildFactory>
var newChild = (await factoryPortal.Create()).MyChild; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Rocky,
I'm having issues creating a new item from the UI to add to an EditList.
The CustomerEditList contains objects that are roots of the CustomerEdit class.
When I fetch from the DataPortal side, everything works fine and I can add objects to the list. CSLA automatically marks them as IsChild.
But on the client side, I can't do this. When I create an object of the CustomerEdit class, its IsChild property is false by default. I'm not sure how to force IsChild to be true when creating the object on the DataPortal side, as there is no Set method by design. In CSLA 4.5, I used to do this directly when creating the object: if it was meant to be added to an EditList, I would set IsChild = true; otherwise, I would leave it as a normal root object that would return to the UI.
In CSLA 8, what is the correct way to create an object for the list so that it can be added to it? I couldn't find an example in CSLA projects.
Thank you very much
Beta Was this translation helpful? Give feedback.
All reactions