Unable to use parameters in DataPortal_Create in CSLA 4.0.1

Unable to use parameters in DataPortal_Create in CSLA 4.0.1

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

Mr X posted on Friday, March 25, 2011


I am unable to specify parameters to my object's DataPortal_Fetch method.  I seem to have read somewhere that this method should accept parameter of any built-in type (int, string...) or criteria objects. 

protected override void DataPortal_Create(MyCriteria Criteria)


                    //TODO: load default values

                    //omit this override if you have no defaults to set

                    using (BypassPropertyChecks)


                        change values here




  I tried that but I always get the following compile error:

(DataPortal_Create()) no suitable method found to override.

The problem does not seem to be the type of parameter but the syntax of the method's declaration.  I tried using the same private declaration as used for the other data access methods (private void) but that did not work either.  What I am not doing or doing wrong?  Any lead would be appreciated.



RockfordLhotka replied on Friday, March 25, 2011

There is only one DataPortal_Create in the base class, and it takes no parameter.

You can only override a method if it exists in the base class - that's the way C# and VB work.

So if you declare a DataPortal_Create that has a parameter, then there is no corresponding base class method, so there's nothing to override.

In that case you just do this:

private void DataPortal_Create(MyCriteria criteria)

Mr X replied on Friday, March 25, 2011

This works! Thanks Rocky,

I did try this yesterday but it was not working.  Must have had a typo or something. 

What a difference a day makes. 

Thanks again.

Copyright (c) Marimer LLC