I am using ADO.Net DataServices to expose an Entity Data Model to Silverlight. The model has a stored procedure that returns void. I want to call this procedure from the Silverlight client.
My understanding is that I should add a [WebInvoke] method to the DataService class and use DbCommand to call the stored procedure.
Here is my code so far:
using System.Data.Common;
using System.Data.Services;
using System.ServiceModel.Web;
namespace Foo.Web
{
public class PayrollDataService : DataService<Foo.Web.PayrollEntities>
{
public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.UseVerboseErrors = true;
}
[WebInvoke]
public void RunMyProcedure()
{
DbConnection conn = this.CurrentDataSource.Connection;
DbCommand cmd = conn.CreateCommand();
// TODO: Call the stored procedure in the EF Data Model.
}
}
}
Can someone confirm that this is the right approach and show an example using DbCommand in this situation?