Child_Create with a parameter?

Child_Create with a parameter?

Old forum URL:

TSF posted on Friday, July 08, 2011

I created an Editable Child object using the provided template, and the Child_Create method overrides the base.  The base siganture doesn't contain a parameter.

Can I just declare my Chlid_Create as private (not overidden) and add the needed parameter as necessary?  Any problems with that?  Would I still need to call base.Child_Create() at the end like normal? Thanks.

[Edit] I should have read further in the DataAccess e-book.  I now realize that when Child_Insert() is called, I can pass in the necessary arguments there.  So I think I'm good.

rxelizondo replied on Friday, July 08, 2011

You will normally call "DataPortal.CreateChild()" with whatever parameter you need, for example:

DataPortal.CreateChild<YourType>(param1, param2, etc);

As long as you have a "Child_Create()" function with parameters that match the same arguments you used on the "DataPortal.ChreateChild()" call you should be OK. Example:


DataPortal.CreateChild(123, "abc");

private void Child_Create(int someNumber, string someString)




The "Child_Create()" build in the CSLA is there just for your convenience since most of the times the default implementation provided by the CSLA is good enough so you are spare the trouble  of typing the same thing over and over again.

Don't forget about the calling "BusinessRules.CheckRules()" if you need to do that. And I think that if you are using Silverlight you may have to make the "Child_Create()" function public but I am not sure about that since I try to avoid Silverlight and all its restrictions (something that i am sure I will come to regret pretty soon).

By the way, on your post your talk about Child_Create but in your edit you mention Child_Insert, I assume you meant Child_Create.

TSF replied on Friday, July 08, 2011

Thanks for the info.  Actually, I did mean to refer to Child_Insert in my edit, because when I saw that the Insert method allowed parameters I realized I could pass what I needed to at that point and still be okay.  But it is good to know that I can make a Child_Create method with parameters if I need to.

tiago replied on Friday, July 08, 2011

DataPortal mehtods accept exactly ONE parameter. If you need to pass 2 or more parameters, you must:

1)  Create a Criteria Class

2) Populate your class with as much properties as you need to pass to the DataPortal method

3) Instanciate our class aand set the properties of the class as you see fit.

4) Call your dataPortal method passing it your instance of the class

Example  need to pass FatherName and MotherName

private class CriteriaParentNames


    public string MotherName { get;set; }

    public string FatherName { get; set; }

    public CriteriaParentNames(string mother, string father)


        MotherName  = mother;

        FatherName  = father;



private Child_Create(CriteriaParentNames crit)


    var myMother = crit.MotherName;

    var myFather = crit.FatherName;


In you code you invoke it like this

DataPortal.Create(new CriteriaParentNames{Josefine", "Napoleon"})

Of course you should use PropertyInfo for properties, etc

rxelizondo replied on Friday, July 08, 2011

I believe he was talking about "DataPortal.CreateChild" (children creation) not "DataPortal.Create" (root object).

Copyright (c) Marimer LLC