Sending parameter to DataPortal_Create()

Sending parameter to DataPortal_Create()

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


CrikeyMoses posted on Tuesday, November 15, 2011

We are using Csla 4.1, Silverlight 4 and MVVM. 

We have some custom validations that depends on two different business objects,

I want to know if it is possible to send a parameter to the DataPortal_Create(), something like the following:

So in my view model i will call the Business.Client method as follows:
public ParticipantVM(string compId)

{ BeginRefresh("NewParticipant", compId); }

 


On the Business.Client side i want to do a call similar to the following;
public static void NewParticipant(string compId, EventHandler<DataPortalResult<Participant>> callback)

 {

            var dp = new DataPortal<Participant>();

            dp.CreateCompleted += callback;

            dp.BeginCreate();  <-- This is where i want to pass the parameter like this dp.BeginCreate(compId);

 }

Then obviously on the Business.Server side I want to catch it:
protected override void DataPortal_Create(string compId)

{}

 

Can someone please me if this is possible and how to achieve it.

Thanks

 

CrikeyMoses replied on Wednesday, November 16, 2011

Is there any way to send parameters to the DataPortal_Create(), if i try is tells me there is no override for DataPortal_Crate(params)

edore replied on Wednesday, November 16, 2011

Hi!

Of course there is no override, Rocky doesn't know your virtual methods signature required in BusinessBase in order to support your scenarios, plus mine, and theirs...  But he uses reflection to find a signature that must look like this if you pass one string parameter for example :

 

        protected void DataPortal_Create(string name)
        {
        }

ryansilva replied on Tuesday, December 27, 2011

Is it possible to pass multiple parameters in create function ?

tiago replied on Tuesday, December 27, 2011

I'm afraid you can't do it: just one parameter allowed.

If you need to pass several parameters build a Criteria Class with where the class properties are your parameters. If you are using Silverlight, make sure that the Criteria Class inherits from CriteriaBase or even BusinessBase.

P.S. - If you are using Silverlight, you must also pass the parameter

Csla.DataPortalClient.LocalProxy<Doc>.CompletedHandler handle

[Edit]

Please refer to http://forums.lhotka.net/forums/p/10506/49151.aspx#49151

[Edit end]

 

Copyright (c) Marimer LLC