In the pass, I have learned how to use CommandBase in BusinessBase as a Business rule.
My question here is How can I use it in my silverlight application directly, just like use any other BusinessBase classes.
The task is that, in silverlight app I have a button, when user click the button, it need to fire a database store procedure call and this procedure just move some rows from one table to another. The user just need to know if the store procedure finished or not. That's it.
I was trying to avoid to create an simple ReadOnly BusinessBase Object just for firing such call to the database.
Can anyone point me to the right direction, an example maybe ?
Thanks,
CommandBase works almost the same in SL as in .NET.
I do walk through an example of using a CommandBase in my CSLA .NET for Silverlight video series, including demo code.
There are two main differences from .NET:
So a command object looks (more or less) like this in SL:
using Csla;
using Csla.Serialization;
[Serializable]
public class MyCommand : CommandBase
{
public MyCommand()
{ }
public MyCommand(string someValue)
{
this.SomeValue = someValue;
}
private static PropertyInfo<string> SomevalueProperty =
RegisterProperty<string>(typeof(MyCommand), new PropertyInfo<string>("SomeValue"));
public string SomeValue
{
get { return ReadProperty(SomeValueProperty); }
set { LoadProperty(SomeValueProperty, value); }
}
public static void DoWork(
EventHandler<DataPortalResult<MyCommand>> callback,
string someValue)
{
var dp = new DataPortal<MyCommand();
dp.ExecuteComplete += callback;
dp.BeginExecute(new MyCommand(someValue));
}
protected override void DataPortal_Execute()
{
// do server-side stuff here
}
}
Thank you Rock
It works perfectly. except in the "DoWork" factory function, your custom parameter must put before EventHandler.
In my code, I create three properties
Can I bind those command properties to my UI elements just like I bind BB object?
CommandBase doesn’t fully support data binding like BusinessBase,
no. It doesn’t support data binding on the Windows side either.
Rocky
Copyright (c) Marimer LLC