QuoteReplyTopic: Using Stored Proc in MVVM Light example Posted: 25-Apr-2013 at 4:24pm
I have watched and followed the video "MVVM Light with DevForce (Silverlight)", which was a great help. Now I am stuck with how to utilise the "Function Import" of a stored procedure returning a list of Entities.
If for example (from the example above) I create a Stored Proc that retrieves Customers where Country = parameter 1 and Region = parameter 2
(obviously this could be done using Linq but I want to show this as an example of parametised sprocs).
eg SQL would "EXECUTE usp_CustomerCtyReg 'USA', 'OR'"
In my dataservice I would try it this way - varying from the video example by calling the LoadCustomersViaSPQuery:
public void LoadCustomersViaSPQuery( Action<IEnumerable<Customer>> success = null, Action<Exception> fail = null)
{
// Call the StoredProc for this
Manager.RetrieveSPCustomersQuery(pCountry: "USA", pRegion: "OR")
.ExecuteAsync(op =>
{
if (op.CompletedSuccessfully)
{
if (null != success)
{
success(op.Results);
}
}
else
{
if (null != fail)
{
op.MarkErrorAsHandled();
fail(op.Error);
}
}
});
}
However, the success(op.Results) is erroring - "Delegate .... has some missing arguments."
Once I sought that out I imagine (and probably incorrectly) the ViewModel should just follow the remainder of the example.
Anyhow, can someone please provide me with the "how to" based on the video example?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum